home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / question / 13144 < prev    next >
Encoding:
Internet Message Format  |  1992-11-09  |  4.1 KB

  1. Path: sparky!uunet!spool.mu.edu!agate!doc.ic.ac.uk!uknet!mcsun!sunic!sics.se!eua.ericsson.se!euas39c40!euabem
  2. From: euabem@eua.ericsson.se (Bertil Engelholm)
  3. Newsgroups: comp.unix.questions
  4. Subject: rm Question (was : C-shell Question
  5. Message-ID: <1992Nov9.082404.10160@eua.ericsson.se>
  6. Date: 9 Nov 92 08:24:04 GMT
  7. Sender: news@eua.ericsson.se
  8. Reply-To: euabem@eua.ericsson.se
  9. Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
  10. Lines: 103
  11. Nntp-Posting-Host: euas39c40.eua.ericsson.se
  12.  
  13. Hi, again
  14.  
  15. Thanks again for all your answers.
  16. Due to my bad english in my two last articles it seems like I mislead most 
  17. of you out there, sorry about that :(.
  18.  
  19. But one answer I got indicates that it seems to be something 
  20. wrong with the command 'rm'. So it is not really a C-shell or
  21. rsh problem (or my mistake :) ).
  22.  
  23. I share this answer with you and asks if someone can answer the question 
  24. why the command 'rm' don't work as expected. (is it a bug or a feature :) ? )
  25.  
  26. /Bertil
  27.  
  28. From bortz@cnam.cnam.fr Thu Nov  5 17:44:11 1992
  29. Date: Thu, 5 Nov 1992 17:43:56 +0100
  30. From: Stephane Bortzmeyer <bortz@cnam.cnam.fr>
  31. To: euabem@eua.ericsson.se
  32. Cc: bortz@cnam.cnam.fr, letondal@cnam.cnam.fr, wandel@cnam.cnam.fr
  33. Subject: Re: C-Shell question
  34. Content-Length: 1355
  35.  
  36. A few minutes after I replied, I followed my own advice and wrote the following script:
  37.  
  38. #!/bin/csh
  39.  
  40. /bin/rm $1 
  41.  
  42. if ( $status != 0 ) then
  43.     echo 'My damned script failed'
  44.     exit 1
  45. endif
  46.  
  47. echo 'Yeah, I did it'
  48. exit 0
  49.  
  50. That's really amazing, but when I run it interactively, it works in both cases (file exists or not) and when it's run under 'rsh', the $status after rm is always 0!!! (I can see that because of the message.)
  51. I simply don't understand. I'm working on it (Cc: people can help me, do they?).
  52.  
  53. This script has the correct behaviour if I replace 'rm' by another command (like 'mv'). Therefore, I suspect a problem with 'rm' which apparently doesn't set $status if not run from a tty.
  54.  
  55. Stephane Bortzmeyer           Conservatoire National des Arts et Metiers    
  56. bortzmeyer@cnam.cnam.fr       Laboratoire d'Informatique
  57.                               292, rue Saint-Martin            
  58. tel: +33 (1) 40 27 27 31      75141 Paris Cedex 03
  59. fax: +33 (1) 40 27 27 72      France    
  60.  
  61. "C'est la nuit qu'il est beau de croire a la lumiere." E. Rostand
  62.  
  63. =================================================================
  64.  
  65. From bortz@cnam.cnam.fr Fri Nov  6 09:04:51 1992
  66. To: comp-unix-questions@ucbvax.berkeley.edu
  67. Cc: bortz@cnam.cnam.fr, letondal@cnam.cnam.fr, wandel@cnam.cnam.fr,
  68.         euabem@eua.ericsson.se
  69. Newsgroups: comp.unix.questions
  70. Distribution: world
  71. From: bortzmeyer@cnam.cnam.fr (Stephane Bortzmeyer)
  72. Organization: cnam
  73. Subject: Re: C-Shell question
  74. Date: Fri, 06 Nov 92 09:04:43 +0100
  75. Sender: bortz@cnam.cnam.fr
  76. X-Mts: smtp
  77. Content-Length: 1365
  78.  
  79. In article <1992Nov4.080338.9458@eua.ericsson.se>,
  80. euabem@eua.ericsson.se (Bertil Engelholm) writes:
  81. [problem with 'rm' under 'rsh']
  82. > All the answers is saying that the exit-code stored in $status is the result
  83. > code of rsh. But how can that happen ? How can the result code of rsh be stored
  84. > in the $status variable before rsh has executed all of the script ?
  85.  
  86. There is something funny with 'rm'. If I write the following script:
  87.  
  88. #!/bin/csh
  89. /bin/mv $1 trash
  90. if ( $status != 0 ) then
  91.     echo 'My damned script failed'
  92.     exit 1
  93. endif
  94. echo 'Yeah, I did it'
  95. exit 0
  96.  
  97. and execute it when the file given as $1 doesn't exist, everything is
  98. fine. I get the 
  99. message 'My damned script failed' when I launch it interactively or threw 'rsh'.
  100.  
  101. If I replace 'mv' with 'rm', I ALWAYS GOT THE MESSAGE 'Yeah, I did it'
  102. wether $1 exists 
  103. or not, as soon as the script is used by 'rsh'! 
  104.  
  105. Other commands behave as 'mv'. Now, there's clearly something wrong
  106. with 'rm'. Is it 
  107. possible it doesn't set $status when run without a tty???
  108.  
  109. Stephane Bortzmeyer           Conservatoire National des Arts et Metiers    
  110. bortzmeyer@cnam.cnam.fr       Laboratoire d'Informatique
  111.                               292, rue Saint-Martin            
  112. tel: +33 (1) 40 27 27 31      75141 Paris Cedex 03
  113. fax: +33 (1) 40 27 27 72      France    
  114.  
  115. "C'est la nuit qu'il est beau de croire a la lumiere." E. Rostand
  116.