From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 11-SEP-1989 01:42
To:	MRGATE::"ARISIA::EVERHART"
Subj:	batch.com which sets up batch enviroment as when you submit it

Received: From CUNYVM.CUNY.EDU by CRVAX.SRI.COM with TCP; Sun, 10 SEP 89 22:03:38 PDT
Received: from YMIR.BITNET by CUNYVM.CUNY.EDU (IBM VM SMTP R1.2.1MX) with BSMTP id 4994; Mon, 11 Sep 89 01:04:17 EDT
Message-Id: <56889628545FA0209D@YMIR.BITNET>
Received: from FRIDAY.A-T.COM by YMIR.BITNET; Sun, 10 Sep 89 17:14 PDT
Date: Sun, 10 Sep 89 17:11 PDT
From: Portia Shao <@YMIR.BITNET:PORTIA%FRIDAY.A-T.COM@CUNYVM.CUNY.EDU>
Subject: batch.com which sets up batch enviroment as when you submit it
To: info-vax@kl.sri.com
X-Vms-To: IN%"info-vax@kl.sri.com"

To get your batch job to start at the current directory and more...

The following is a command procedure I use all the time to submit batch jobs
it is much easier than writing three line tmp.com's to do your simple commands
in batch. It takes either the command on the same line or you can type in
as many lines as you want to be batched (as one batch job). It sets up
the default directory to be when you invoke the batch command,
it does not set up the priv's to be the same however,
it also lets you specify qualifiers to the SUBMIT command so you can submit
it for another user (if you have cmkrnl priv) or submit it for later or
a different queue, etc...


        /Portia Shao    portia@ashtate.a-t.com
        Ashton-Tate, Torrance, CA       (213) 538-6285


$! change history at the end of this file (Batch.com)
$ save_verify = 'f$verify(0)'
$ save_message = f$environment("message")
$ set message/notext/noseverity/nofacility/noident
$ curdir = F$environment("DEFAULT")
$ n = 2
$ qualifier = ""
$ command = ""
$ prcnam = ""
$ If p'n' .eqs. "" Then Goto PROMPT_COMMANDS
$QUALIFIER_LOOP:
$ if f$locate("/",p'n').eq.f$length(p'n') then goto GET_COMMAND
$ if f$locate("/",p'n').ne.0 then goto GET_COMMAND
$ qualifier = qualifier + p'n'
$ n = n+1
$ if n.le.8 then goto QUALIFIER_LOOP
$ goto PROMPT_COMMANDS
$GET_COMMAND:
$ m = n
$COMMAND_LOOP:
$ Command = command + p'm' + " "
$ m = m + 1
$ if m.le.8 then goto COMMAND_LOOP
$GET_PRCNAM:
$ prcnam = p'n'
$ start = F$locate("@",prcnam) + 1
$ length = F$length(prcnam) - start
$ If length .ge. 0 Then prcnam = F$extract(start,length,prcnam)
$ start = F$locate(":",prcnam')+ 1
$ length = F$length(prcnam) - start
$ If length .ge. 0 Then prcnam = F$extract(start,length,prcnam)
$ start = F$locate("]",prcnam) + 1
$ length = F$length(prcnam) - start
$ If length .ge. 0 Then prcnam = F$extract(start,length,prcnam)
$ length = F$locate(".",prcnam)
$ If length .ne. F$length(prcnam) Then prcnam = F$extract(0,length,prcnam)
$ length = F$locate("/",prcnam)
$ If length .ne. F$length(prcnam) Then prcnam = F$extract(0,length,prcnam)
$ command = f$edit(command, "TRIM")
$ if command.nes."" then goto MANYLINES
$PROMPT_COMMANDS:
$ Write Sys$output "Enter commands, start each with ""$"". Terminate with CTRL/Z
   ."
$ assign/user sys$command: sys$input:
$ on control_y then goto OUT
$ Create batch.tm1
$ open/read/error=out2 bat_commands batch.tm1
$MANYLINES:
$ If f$length(prcnam) .eqs. 0 Then prcnam = "batch"
$ on warning then goto BADNAME
$ open/write tmpfile sys$login:'prcnam'.tmp
$ Write tmpfile "$ set noon"
$ write tmpfile "$ set verify"
$ Write tmpfile "$ set default ''curdir'"
$ write tmpfile "$logstart:"
$ If command .nes. "" Then goto ONELINER
$TMPCMD_LOOP:
$ read/end=eof bat_commands line
$ write tmpfile line
$ goto TMPCMD_LOOP
$EOF:
$ close bat_commands
$ delete/noconfirm batch.tm1;0
$ goto RESUME
$ONELINER:
$ Write tmpfile "$''COMMAND'"
$RESUME:
$ Write tmpfile "$logend:"
$ Write tmpfile "$ stat = $status                       ! 'f$verify(0)'"
$ Write tmpfile "$ msg := ""Errors in ''prcnam'."""
$ Write tmpfile "$ if stat then msg := ""''prcnam' finished"""
$ Write tmpfile "$ thisfile = f$env(""PROCEDURE"")"
$ Write tmpfile "$ delete/noconfirm 'thisfile'"
$ Write tmpfile "$ logout"
$ Close tmpfile
$ submit/notify/noprinter'qualifier' sys$login:'prcnam'.tmp
$ status = $status
$ listl*og :== 'list' sys$login:'prcnam'.log /%$LOGSTART:/+1,/%$LOGEND:/-1FP
$! the above uses the list program from ICR on fall 82 decus tape
$ dell*og :== delete/noconfirm sys$login:'prcnam'.log;*
$OUT2:
$ set message 'save_message'
$ if save_verify then set verify
$ if status then exit
$ exit 'status'
$OUT:
$ if p1 .eqs. "" Then delete/noconfirm batch.tm1;0
$ goto OUT2
$BADNAME:
$ prcnam = ""   ! assume the prcnam is not valid filename
$ goto MANYLINES
$!
$!  BATCH.COM
$!
$!  Modified by Portia Shao  Portia@ashton.a-t.com
$!       7-JUL-1989 15:10:55.73 to support qualifiers on the SUBMIT command
$!  Modified for use with batch by Bill Wood from SPAWN.COM
$!      Institute For Cancer Research
$!      7701 Burholme Ave.
$!      Philadelphia, Pa. 19111
$!      (215) 728-2760
$!
$!  SPAWN.COM originally by:
$!          Ira Winston
$!          Computer Science Department
$!          University of Pennsylvania
$!          200 South 33rd Street
$!          Philadelphia, Pennsylvania  19104
$!          (215) 243-4707
$!
$!  To use put "$BAT*CH :== @dirxyz:BATCH dummy" into your LOGIN.COM file.
$!  where dirxyz is your system utilities directory
$!
$!  The BATCH command is a convenient way to submit a batch job.
$!  For instance you could say
$!
$!  BATCH COPY *.* [.TMP]                                 or
$!  BATCH /QUE=SPECIAL_QUE /AFTER=TOMORROW COPY *.* [.TMP]
$!
$!  the qualifiers preceding the command are assumed to be qualifiers to
$!  the SUBMIT command. If there is no command on the same line, then
$!  you will be prompted to enter the commands.
$!
$!  You have to define p1 as a dummy parameter, otherwise you can not start
$!  it with a / without quoting it.
$!
$!  The BATCH command creates a file in your home directory.  It tries to
$!  name the file according to the command you are executing; in the preceding
$!  example, the file would be called COPY.LOG.  If it can't figure out a
$!  name, it uses BATCH.LOG.
$!
$!  It also defines two commands for you; LISTL*OG which types the LOG file and
$!  DELL*OG which deletes the log file. (LIST is part of DECUS contribution
$!  from ICR in 82, redefine it to be other commands if you don't have LIST)
$!
$!  The BATCH command also notifies you when the batch process has finished.
$!  You can BATCH more than one command simultaneously, but the LISTL*OG and
$!  DELL*OG commands refer to the last BATCH command issued.
$!
$!  BATCH tries to set up the environment in the batch process so that it
$!  is similar to your current environment.
$!  It sets the default directory to your current default directory,

