home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / admin / 7001 < prev    next >
Encoding:
Text File  |  1993-01-09  |  1.9 KB  |  71 lines

  1. Newsgroups: comp.unix.admin
  2. Path: sparky!uunet!gatech!udel!gvls1!jabber!candle!root
  3. From: root@candle.uucp (Bruce Momjian)
  4. Subject: Re: Batch processing in Unix
  5. Organization: a consultant's basement
  6. Date: Sat, 9 Jan 1993 03:55:42 GMT
  7. Message-ID: <1993Jan9.035542.2962@candle.uucp>
  8. X-Newsreader: TIN [version 1.1 PL6]
  9. References: <1ii9hjINNpdg@parlo.hal.COM>
  10. Lines: 59
  11.  
  12. If you run system V, you can use the print spooler as a batch queue
  13. mechanism.  Replace the interfaces program with this one, and use lp -d
  14. to sumit, lpstat to observe, and cancel to delete.
  15.  
  16. -------------------------------------------------------------------
  17. trap 'exit' 15
  18. exit_code=0
  19.  
  20. : ${TMPDIR:=/tmp}
  21. : ${SPOOLDIR:=/usr/spool/lp}
  22. : ${TERMINFO:=/usr/lib/terminfo}
  23. : ${CHARSETDIR:=/usr/lib/charsets}
  24.  
  25. : ${LOCALPATH:=${SPOOLDIR}/bin}
  26. PATH="/bin:/usr/bin:${LOCALPATH}"
  27.  
  28. catch_hangup () {
  29.     echo "The batch queue was sent a hangup.  Job terminated." 1>&2
  30.     return 0
  31. }
  32. catch_interrupt () {
  33.     echo "Received an interrupt from the batch queue." 1>&2
  34.     return 0
  35. }
  36. trap 'catch_hangup; exit_code=129 exit 129' 1
  37. trap 'catch_interrupt; exit_code=129 exit 129' 2 3
  38.  
  39. request_id=$1
  40. user_name=$2
  41. shift 5
  42. files="$*"
  43. HOME=`grep "^$user_name:" /etc/passwd | cut -d: -f6`;export HOME
  44. LOGNAME="$user_name" ; export LOGNAME
  45. MAIL="/usr/mail/$user_name" ; export MAIL
  46. cd $HOME
  47. while [ "$#" -gt 0 ]
  48. do
  49.     if [ -r $1 ]
  50.     then    
  51.         
  52. #        (cat /etc/profile $HOME/.profile;
  53. #         echo 'set -x'; cat $1 ) | sh 1>&2
  54.         cat /etc/profile $HOME/.profile $1 | sh 1>&2
  55.     else     echo "File $1 does not exist."
  56.         exit_code=1
  57.     fi
  58.     shift
  59. done
  60. if [ $exit_code -ne 0 ]
  61. then
  62.     echo "Batch job had errors." 1>&2
  63. fi
  64. exit $exit_code
  65.  
  66. -- 
  67. Bruce Momjian                          |  830 Blythe Avenue
  68. root%candle.uucp@bts.com               |  Drexel Hill, Pennsylvania 19026 
  69.   +  If your life is a hard drive,     |  (215) 353-9879(w) 
  70.   +  Christ can be your backup.        |  (215) 853-3000(h)
  71.