Shell output directed to program (HELP)

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Fri May 17 12:41:35 AEST 1985


> ... I need to know if there is a way
> to pass strings input to this program to the shell
> for execution (such as pwd or cd etc.) and have
> the resulting output from the shell directed back
> to the program ...

Sure, but you have to be careful.  Trying to attach pipes
for both input & output from the subshell is too hard,
since the possibility of deadlock exists.  Put input for
the subshell into a file, then invoke the popen() library
function to run "shellname <filename" in "r" mode,
followed by invocations of getc() to read the output
returned from the shell.



More information about the Comp.unix mailing list