home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / sgi / 12986 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  2.1 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!jvnc.net!rutgers!sgigate!odin!fido!agomoda!williams
  2. From: williams@agomoda.asd.sgi.com (Eric Williams)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re: batch, at and rc=1
  5. Message-ID: <p3urmlc@fido.asd.sgi.com>
  6. Date: 27 Aug 92 19:43:41 GMT
  7. References: <32240@adm.brl.mil>
  8. Sender: news@fido.asd.sgi.com (Usenet News Admin)
  9. Organization: Silicon Graphics, Inc.  Mountain View, CA
  10. Lines: 50
  11.  
  12. In <32240@adm.brl.mil> beyer@bflsgu.fl.bs.dlr.de (R. Beyer) writes:
  13. >
  14. >However, further studies on an Indigo running IRIX 4.0.1 have shown
  15. >the following curiosity: If identical scripts exist to be submitted
  16. >to 'at' or 'batch' whereby one script is named 'test' and the other
  17. >is named 'test.xyz' the latter is executed as expected while the script
  18. >named 'test' is not executed and gets a tag "rc=1" in the cron logfile.
  19. >I include a session log. Does anybody have an explanation for this
  20. >behaviour ?
  21.  
  22. The name 'test' has special significance to the Bourne shell (/bin/sh).
  23. From the sh(1) man page:
  24.  
  25.      test
  26.           Evaluate conditional expressions. See test(1) for usage and
  27.           description.
  28.  
  29. You can see for yourself that it would fail if you try the following:
  30.  
  31. % /bin/csh
  32. % cat > test
  33. #!/bin/csh -f
  34. echo "Hello, World"
  35. ^D
  36. % chmod +x test
  37. % test
  38. Hello, World
  39. % /bin/sh -c test
  40. % echo $status
  41. 1
  42. %
  43.  
  44. The csh status variable is set to the return code of the /bin/sh execution.
  45. From the sh(1) man page:
  46.  
  47. EXIT STATUS
  48.      Errors detected by the shell, such as syntax errors, cause the shell to
  49.      return a non-zero exit status.  If the shell is being used non-
  50.      interactively execution of the shell file is abandoned.  Otherwise, the
  51.      shell returns the exit status of the last command executed (see also the
  52.      exit command above).
  53.  
  54.  
  55. One workaround is to use a different name, as you discovered.  Another workaround
  56. is to use a path name for the script.  This is probably better anyway, since the
  57. current method assumes that you have '.' in your path, which not everyone does.
  58. If you do '/bin/sh -c ./test' or '/bin/sh -c /full/path/to/command/test' it works.
  59.  
  60. Cheers,
  61. Eric Williams
  62.