C: stream to stdin of another program

November 12, 2009 at 09:50:14
Specs: Solaris 10
Program A has a longchar buffer that needs to be streamed to Program B. Program B is expecting the stream via stdin then will output some info to console. How can Program A run Program B and feed its buffer to Program B's stdin and capture Program B's stdout?

A code snippet for Program A would be very helpful.


See More: C: stream to stdin of another program

Report •


#1
November 13, 2009 at 06:37:26
Use popen()

Report •

#2
November 13, 2009 at 09:49:11
Razor, I was thinking of replying with popen too, but as I
understand, that's only one-way. How do you send input to the
spawned program AND get its output?

Report •

#3
November 13, 2009 at 10:36:20
If popen doesn't work, perhaps the fork() command is an option. Here is an example using fork:

http://www.computing.net/answers/so...

Also, here is an article discussing popen and fork():

http://www.theillien.com/Sys_Admin_...


Report •

Related Solutions


Ask Question