home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / perl / 7782 < prev    next >
Encoding:
Text File  |  1993-01-12  |  755 b   |  32 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!newsflash.concordia.ca!hobbit.ireq.hydro.qc.ca!guy
  3. From: guy@mais.hydro.qc.ca (Guy Harel)
  4. Subject: How to get to $? of /bin/sh
  5. Message-ID: <guy.726876346@tdsb-s>
  6. Sender: news@ireq.hydro.qc.ca (Netnews Admin)
  7. Organization: Hydro-Quebec (DSB)
  8. Date: Tue, 12 Jan 1993 22:05:46 GMT
  9. Lines: 21
  10.  
  11. Hi,
  12.  
  13. I`m new to PERL, and would like to know how to get the value of
  14. the status var ($?) of a command submitted to the SH:
  15.  
  16. For example the following gets rid of the error message, as I want:
  17.  
  18.     $status=`cp >/dev/null 2>&1`;
  19.  
  20. But if I try to print $? on the second line, I get '0' since the PERL
  21. line executed without problems.
  22.  
  23. Can I get to $? without resorting to:
  24.  
  25.     $status=`cp 2>/dev/null; echo $? `;
  26.  
  27.  
  28. Thanks
  29.  
  30. -- 
  31. --
  32.