home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / next / programm / 5972 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  938 b 

  1. Path: sparky!uunet!olivea!hal.com!decwrl!csus.edu!news
  2. From: eps@futon.SFSU.EDU (Eric P. Scott)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: Can I pass variables to system()?
  5. Message-ID: <1992Sep4.082118.17128@csus.edu>
  6. Date: 4 Sep 92 08:21:18 GMT
  7. References: <21376@optima.cs.arizona.edu>
  8. Sender: news@csus.edu
  9. Reply-To: eps@cs.sfsu.edu
  10. Organization: San Francisco State University
  11. Lines: 15
  12.  
  13. In article <21376@optima.cs.arizona.edu> kline@cs.arizona.edu
  14.     (Nick Kline) writes:
  15. >   sprintf(string,"cal %d %d > /tmp/calOutputFile",theMonth,theYear);
  16. >   system(string);
  17.  
  18. The general rule on any UNIX system (this is not NeXT-specific)
  19. is that you want to prefix a simple external command with an
  20. "exec" verb to avoid having an extraneous shell process lying
  21. around, i.e.:
  22.  
  23.    sprintf(string,"exec cal %d %d > /tmp/calOutputFile",theMonth,theYear);
  24.  
  25.                     -=EPS=-
  26. -- 
  27. Try  system("ps -t"); system("exec ps -t");  to see the difference.
  28.