Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!wuarchive!udel!princeton!phoenix!pfalstad From: pfalstad@phoenix.Princeton.EDU (Paul John Falstad) Newsgroups: comp.unix.questions Subject: Re: Interfacing C Code to Shell Script Keywords: popen sucks ;-) Message-ID: <16890@phoenix.Princeton.EDU> Date: 31 May 90 04:06:26 GMT References: <23487@adm.BRL.MIL> <16870@phoenix.Princeton.EDU> <11985@cbmvax.commodore.com> Reply-To: pfalstad@phoenix.Princeton.EDU (Paul John Falstad) Organization: Princeton University, NJ Lines: 25 In article <11985@cbmvax.commodore.com> ag@cbmvax (Keith Gabryelski) writes: >In article <16870@phoenix.Princeton.EDU> subbarao@phoenix.Princeton.EDU >(Kartik Subbarao) writes: >>In article <23487@adm.BRL.MIL> rose@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@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.