home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / programm / 4494 < prev    next >
Encoding:
Text File  |  1992-08-30  |  1006 b   |  32 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!ames!sun-barr!cs.utexas.edu!wupost!gumby!destroyer!ubc-cs!uw-beaver!uw-coco!nwnexus!jhgrud!polari!errant@polari.online.com
  3. From: errant@polari.online.com
  4. Subject: Need help with System()
  5. Message-ID: <1992Aug28.140705.501@polari>
  6. Summary: System() wont work correctly
  7. Keywords: Need help with System()
  8. Organization: Seattle Online Public Access Unix.  (206) 328-4944 (all lines telebit-equipped)
  9. Date: Fri, 28 Aug 1992 14:07:05 GMT
  10. Lines: 20
  11.  
  12. Am unit testing a much larger program, and have run into a glitch
  13. with the below code:
  14. main()
  15. {
  16.   if (system ("/bin/ps -el | /usr/bin/fgrep -c cron") == 1)
  17.      printf ("good\n");
  18.   else
  19.      printf ("bad\n");
  20. }
  21.  
  22. When program is run the following results:
  23. #a.out
  24. 1
  25. bad
  26. #
  27.  
  28. As can be seen, it shows that 1 is how many times cron is
  29. detected, but then it drops through and prints bad.  What gives??
  30. Is there something I could add to the code that would show me??
  31. I'm stumped!
  32.