Solved

Piping Data from/to Other Program in UNIX

Posted on 1998-01-11
2
217 Views
Last Modified: 2010-04-02
Hello,
I'm re-teaching my self C and am trying to do something that I have seen in PERL but doesn't appear to work the same in C. In PERL you can open a pipe to another program using the regular file open command. You do this by using the name of the program you want to pipe as the file name in the open command with the pipe character either before or after the program name depending on weather you want to pipe data in or out. Ounce its open you can read or write to it the same way you would to a disk file.

Now, I know that C uses the same concept of streams and piping is built into the UNIX environment so I'm pretty sure you can do it but I suspect the method is a little different then opening a disk file in C. Can anybody tell me how?

Thanks
0
Comment
Question by:grobin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
julio011597 earned 50 total points
ID: 1256975
Yes, you are quite near to it.

The rilevant functions are popen() and pclose() (include <stdio.h>).

popen() returns a pointer to FILE, so you work with this pointer the same way you would with any "regular" file.

Try man popen for further details.

Regards
0
 

Author Comment

by:grobin
ID: 1256976
yup, that did it. Thanks a bunch


0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question