parm _job,char='!',at='',day='',date='', in='',user='',group='',account='', & jobname='',outclass='LP',inpri='',pri='ES',time='?', jobappend=''& jobinfo=' ',replace='NO',programatic='NO',debug='NO',preprocess='NO' & step='STEP1' # Written by Gary L. Biggs; Nov, 1997 after an example # from Wolfgang Kinscher of HP Austria # # SUBMIT -- Flexible Stream Script that allows stream jobs to be # written as prototypes with variable replacement # in the JOB statement (and an environment variable) # that are resolved when the file is streamed. # It also allows 'normal' job statements to be # appended so that INPRI,OUTCLASS,PRI and TIME # can be specified if they are not already present. # # Mentally replace '~' with an explanation # mark in the following examples: # # N.B. - Stream prototypes should be kept as an unnumbered file # # Sample Job for SUBMIT (TESTJOB -- the STREAM prototype): # # ~job ~hpjobname,~hpuser.~hpaccount,~hpgroup;inpri=~hpinpri; & # ~outclass=~hpoutclass;pri=~hpjobpri;time=~hpjobtime # ~ < some MPE/iX commands > # ~eoj # # Usage Examples: # # SUBMIT testjob -- job logs on with SUBMITing user information # SUBMIT testjob,#;at=23:00;day=MONDAY -- like STREAM command # SUBMIT testjob;OUTCLASS=LASERJET;INPRI=13;PRI=BS # -- as above with output redirected to LASERJET and # sent to the head of the Job Queue # # SUBMIT oldjob;USER=manager;ACCOUNT=sys;JOBNAME=oldjob;REPLACE=yes # -- replaces the 1st line of a conventional stream job # with the prototype shown above. # This lets one redirect an unmodified stream file to a new logon. # # SUBMIT oldjob;JOBAPPEND='outclass=laserjet' # -- takes 1st line of a conventional stream job # and appends the OUTCLASS option to the JOB statement to # redirect the output to a new printer # # SUBMIT testjob;USER=manager/password;ACCOUNT=sys;JOBAPPEND='HIPRI' # -- job logs on as MANAGER.SYS with ;HIPRI added # to the end of the job statement (HIPRI not already specified # in the prototype) # # SUBMIT testjob;JOBINFO='listf @.pub.sys' # -- The JOBINFO parameter passes a string from the # SUBMIT command to the Job Stream (SUBMIT automatically # inserts a definition for an environemnt variable HPJOBINFO # into the temporary file that will be STREAMED) # # Example of the use of the JOBINFO parameter: # ~job howtouse,~hpuser.~hpaccount # ~run ci.pub.sys;info='~HPJOBINFO' << listf @.pub.sys # ~setvar newcommand '~HPJOBINFO' + ',2' # ~~newcommand << listf @.pub.sys,2 # ~eoj # # SUBMIT testjob;USER=manager;ACCOUNT=sys;PROGRAMATIC # -- used with HPCICOMMAND intrinsic PROGRAMATIC redirects # the printing of the JOB number or CIERROR # to the variable SUBMITRESULT that can then be # checked for the results from the programatic # execution of the SUBMIT command file if '!step' = 'STEP1' then xeq !hpfile '!_job',user='!user',group='!group',account='!account', & jobname='!jobname',outclass='!outclass',inpri='!inpri', & pri='!pri',time='!time',jobappend='!jobappend',replace='!replace', & debug='!debug',step='STEP2' *tempjob fcopy from=!_job;to=*tempjob;subset=!_nrecs > $null setvar timespec ' ' if '!at' > ' ' setvar timespec ';AT=' + '!AT' endif if '!day' > ' ' setvar timespec timespec + ';DAY=' + '!DAY' endif if '!date' > ' ' setvar timespec timespec + ';DATE=' + '!DATE' endif if '!in' > ' ' setvar timespec timespec + ';IN=' + '!IN' endif file tempjob,oldtemp setvar cierror 0 if ups('!preprocess') = 'NO' if ups('!programatic') = 'YES' stream tempjob,!char !timespec >submitok if cierror = 0 file submitok,oldtemp input _l < submitok reset submitok setvar submitresult ltrim('!_l') else setvar submitresult '!cierror' endif purge submitok,temp else stream tempjob,!char !timespec endif purge tempjob,temp endif reset tempjob deletevar _l, _nrecs, timespec, _injoblogon else if '!step' = 'STEP2' then file tempjob=tempjob,oldtemp if finfo('*tempjob','exists') then purge tempjob,temp endif file tempjob;temp;disc=![finfo('!_job','end of file')+10] fcopy from=!_job;to=*tempjob;new;subset=0,0 > $null file tempjob=tempjob,oldtemp;acc=append setvar _nrecs 0 setvar _injoblogon 1 while _injoblogon > 0 do if ups('!replace') = 'YES' setvar _l '!!job !!hpjobname,!!hpuser.!!hpaccount,!!hpgroup;' + & 'outclass=!!hpoutclass;pri=!!hpjobpri;time=!!hpjobtime;' + & 'inpri=!!hpinpri' else input _l endif setvar _l ups(_l) setvar _nrecs, _nrecs + 1 setvar _injoblogon pos('&',_l) if '!jobappend' > ' ' and _injoblogon = 0 setvar _l rtrim(_l) + ';'+ '!jobappend' endif if '!jobname' > ' ' setvar _l repl(_l,'!','!!') setvar _l repl('!_l','!!HPJOBNAME','!JOBNAME') endif if '!user' > ' ' setvar _l repl(_l,'!','!!') setvar _l repl('!_l','!!HPUSER','!USER') endif if '!account' > ' ' setvar _l repl(_l,'!','!!') setvar _l repl('!_l','!!HPACCOUNT','!ACCOUNT') endif if '!group' > ' ' setvar _l repl(_l,'!','!!') setvar _l repl('!_l','!!HPGROUP','!GROUP') endif if '!inpri' > ' ' setvar _l repl(_l,'!','!!') setvar _l repl('!_l','!!HPINPRI','!INPRI') endif setvar _l repl(_l,'!','!!') setvar _l repl('!_l','!!HPOUTCLASS','!OUTCLASS') setvar _l repl(_l,'!','!!') setvar _l repl('!_l','!!HPJOBPRI','!PRI') setvar _l repl(_l,'!','!!') setvar _l repl('!_l','!!HPJOBTIME','!TIME') if lft(_l,1) = '!' then setvar _l repl(_l,'!','!!',1) endif if ups('!debug') = 'YES' echo !_l endif echo !_l >*tempjob endwhile endif endif