Interfacing C Code to Shell Script
Andy Behrens
finn at eleazar.dartmouth.edu
Thu May 31 10:59:26 AEST 1990
rose at baby.swmed.utexas.edu (Rose Oguz) writes:
> I want to call a shell script from my C program. However, I
> would like the script to return values to my C program. Is there a
> way to do this? Or must I write the shell output to a file and read the
> contents of the file in my C code?
If you need to return a lot of information, then popen(3) is just the
thing (as another poster has suggested).
However, sometimes you only need to return a small integer, perhaps a
success/failure code. If that's the case, it's easier to call system(3),
and use the shell command
exit N
to return your status.
More information about the Comp.unix.questions
mailing list