home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / shell / 4586 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.6 KB  |  47 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!dkeisen
  3. From: dkeisen@leland.Stanford.EDU (Dave Eisen)
  4. Subject: Re: C-Shell question
  5. Message-ID: <1992Nov7.183512.15357@leland.Stanford.EDU>
  6. Sender: news@leland.Stanford.EDU (Mr News)
  7. Organization: Sequoia Peripherals, Inc.
  8. References: <1992Nov5.020850.572@news.csd.sgi.com> <1992Nov6.115704.23205@cs.utwente.nl> <1992Nov6.113910.21207@ms.uky.edu>
  9. Distribution: na
  10. Date: Sat, 7 Nov 92 18:35:12 GMT
  11. Lines: 34
  12.  
  13. In article <1992Nov6.113910.21207@ms.uky.edu> kherron@ms.uky.edu (Kenneth Herron) writes:
  14. >
  15. >As for Mr. Vidya and the others, it sounds like they didn't read your
  16. >question closely enough and thought you were doing something like
  17. >
  18. >    #! /bin/csh
  19. >    rsh foo /bin/rm file
  20. >    if ( $status ) ...
  21.  
  22. (As opposed to rm -f)
  23.  
  24. No. Mr. Vidya and the others were right, the -f has nothing
  25. at all to do with the functionaltiy of this script.
  26.  
  27. The script you wrote will always have $status set to 0, regardless
  28. of whether or not file exists on foo (assuming you were successfully
  29. able to execute the rm command on foo). The problem with this script
  30. is that it depends on the exit status of rsh which will be 0 even
  31. if the exit status of rm isn't.
  32.  
  33. The only way to find out if the rm worked is to do the following:
  34.  
  35. #! /bin/csh
  36.  
  37.    set stat = `rsh foo 'rm file >& /dev/null ; echo $status '`
  38.  
  39.    if ( $stat ) ....
  40.  
  41.  
  42. -- 
  43. Dave Eisen                               Sequoia Peripherals: (415) 967-5644
  44. dkeisen@leland.Stanford.EDU              Home:                (415) 321-5154
  45.        There's something in my library to offend everybody. 
  46.           --- Washington Coalition Against Censorship
  47.