Interfacing C Code to Shell Script

Paul John Falstad pfalstad at phoenix.Princeton.EDU
Thu May 31 14:06:26 AEST 1990


In article <11985 at cbmvax.commodore.com> ag at cbmvax (Keith Gabryelski) writes:
>In article <16870 at phoenix.Princeton.EDU> subbarao at phoenix.Princeton.EDU
>(Kartik Subbarao) writes:
>>In article <23487 at adm.BRL.MIL> 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
                                        ^
>>this one simply says that popen() is screaming for this job, just as it's
>or just:
>
>	int retval = system("myshellscript");

This only works for one integer return value that is < 128, of course.
If you need more than that you'll have to do a popen.

Also, for a command as simple as "myshellscript," I would have used
fork, execve, and wait, to save on the overhead of sh.  Even instead of
popen it might be a good idea to try fork, execve, and pipe...
Just a thought.

-- 
Paul Falstad  PLINK:Hypnos GEnie:P.FALSTAD net:pfalstad at phoenix.princeton.edu
Disclaimer: My opinions, which belong to me and which I own, are mine.
-Anne Elk (not AN elk!)  The sun never set on the British empire because
the British empire was in the East and the sun sets in the West.



More information about the Comp.unix.questions mailing list