home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.admin
- Path: sparky!uunet!gatech!udel!gvls1!jabber!candle!root
- From: root@candle.uucp (Bruce Momjian)
- Subject: Re: Batch processing in Unix
- Organization: a consultant's basement
- Date: Sat, 9 Jan 1993 03:55:42 GMT
- Message-ID: <1993Jan9.035542.2962@candle.uucp>
- X-Newsreader: TIN [version 1.1 PL6]
- References: <1ii9hjINNpdg@parlo.hal.COM>
- Lines: 59
-
- If you run system V, you can use the print spooler as a batch queue
- mechanism. Replace the interfaces program with this one, and use lp -d
- to sumit, lpstat to observe, and cancel to delete.
-
- -------------------------------------------------------------------
- trap 'exit' 15
- exit_code=0
-
- : ${TMPDIR:=/tmp}
- : ${SPOOLDIR:=/usr/spool/lp}
- : ${TERMINFO:=/usr/lib/terminfo}
- : ${CHARSETDIR:=/usr/lib/charsets}
-
- : ${LOCALPATH:=${SPOOLDIR}/bin}
- PATH="/bin:/usr/bin:${LOCALPATH}"
-
- catch_hangup () {
- echo "The batch queue was sent a hangup. Job terminated." 1>&2
- return 0
- }
- catch_interrupt () {
- echo "Received an interrupt from the batch queue." 1>&2
- return 0
- }
- trap 'catch_hangup; exit_code=129 exit 129' 1
- trap 'catch_interrupt; exit_code=129 exit 129' 2 3
-
- request_id=$1
- user_name=$2
- shift 5
- files="$*"
- HOME=`grep "^$user_name:" /etc/passwd | cut -d: -f6`;export HOME
- LOGNAME="$user_name" ; export LOGNAME
- MAIL="/usr/mail/$user_name" ; export MAIL
- cd $HOME
- while [ "$#" -gt 0 ]
- do
- if [ -r $1 ]
- then
-
- # (cat /etc/profile $HOME/.profile;
- # echo 'set -x'; cat $1 ) | sh 1>&2
- cat /etc/profile $HOME/.profile $1 | sh 1>&2
- else echo "File $1 does not exist."
- exit_code=1
- fi
- shift
- done
- if [ $exit_code -ne 0 ]
- then
- echo "Batch job had errors." 1>&2
- fi
- exit $exit_code
-
- --
- Bruce Momjian | 830 Blythe Avenue
- root%candle.uucp@bts.com | Drexel Hill, Pennsylvania 19026
- + If your life is a hard drive, | (215) 353-9879(w)
- + Christ can be your backup. | (215) 853-3000(h)
-