STREAM ANYPARM streamparms = ![''] OPTION nohelp, recursion # Version A.05 # The STREAM UDC allows system managers to direct certain jobs, based on the # job's logon, to a user defined job queue. This is accomplished via a simple # job queue configuration file which is searched for all streamed jobs that do # not have ";jobq=" specified in the stream command itself, or in the JOB # "card". The default name for this config file is "QFILE.PUB.SYS" but can be # changed by altering the _str_config_file variable defined near the start of # this UDC. # # Config file format: # [jobname,]user.acct jobQueueName # # Spaces or a single semicolon separates the two fields in the file. # Wildcarding is permitted in all names other than the actual job queue name. # More specific entries should procede more generic (wildcarded) entries. Thus, # an individual user.acct name should appear before wildcarding is used in the # user or account names. To specify all users in an account use "@.acctname". # # This UDC uses alternate entry points usually with input or output redirected # to a disk file. The convention is that the last command line argument is # "entry=name", when alternate entries are required. # # Note: interactive STREAM is not supported. A stream jobfile must be # specified. # Note: this UDC requires MPE/iX 6.0 or greater. if "!streamparms" = "" or pos("entry=","!streamparms") = 0 then # main entry point of UDC errclear # user configurable variables next: # *** change this line if you want a different name for the config file setvar _str_config_file 'QFILE.PUB.SYS' # end of user configurable variables setvar _str_jobfile word("!streamparms") if _str_jobfile = "" then echo Interactive stream - enter !!EOJ to end job and :EOD to exit STREAM option norecursion continue stream !streamparms deletevar _str_jobfile return endif if not finfo(_str_jobfile,"exists") then echo "!_str_jobfile" does not exist option norecursion continue stream !streamparms deletevar _str_jobfile return endif # extract and upshift remaining stream parameters, including the delimiter # between the stream file and the first arg. setvar _str_parms ups(repl & (rht("!streamparms",-delimpos("!streamparms"))," ","")) # parse out jobq= name from STREAM command line setvar _str_jobq '' if setvar(_str_pos,pos(";JOBQ=",_str_parms)) > 0 then setvar _str_jobq word(_str_parms,,2,,_str_pos+5) endif if _str_jobq = '' then # no jobq=name in stream command so parse out jobq= name from JOB line # first ensure read access to job file (vs. user having just X access) continue print !_str_jobfile;end=1 >$null if cierror <> 0 then echo User lacks read access to "!_str_jobfile" echo Using standard MPE STREAM command (STREAM UDC skipped) option norecursion continue stream !streamparms deletevar _str_@ return endif # ok to parse the job file continue STREAM _str_jobcard entry=read_jobcard 0 then setvar _str_jobq word(_str_jobcard,,2,,_str_pos+5) endif endif if _str_jobq = '' and finfo(_str_config_file,'exists') then # No jobq=name specified at all so now we can use the config file. If # the job card's [jobname,]user.acct matches an entry in config file # then use that jobq to stream the job. # pass the [jobname,]user.acct from the job card as arg1 continue STREAM ![word(_str_jobcard,";")] _str_jobq entry=read_config & '' then # found a match in config file and got back the jobq name # append jobq name to stream command line echo Match found in "!_str_config_file" jobQ config file. setvar _str_parms _str_parms + ";jobq=!_str_jobq" endif endif # now finally stream the job. if _str_jobq = '' then echo Job file "!_str_jobfile" streamed in default "HPSYSJQ" job queue. else echo Job file "!_str_jobfile" streamed in "!_str_jobq" job queue. endif option norecursion continue stream !_str_jobfile !_str_parms # cleanup deletevar _str_@ return else # alternate entry points for UDC. setvar _str_entry word("!streamparms",,-1) # remove entry=name from parm line setvar _str_entry_parms lft('!streamparms',pos('entry=','!streamparms')-1) if _str_entry = "read_jobcard" then # Arg 1 is the *name* of the var to hold all of the JOB card right of "JOB". # Input redirected to the target job file being streamed. # Read file until JOB card is found. Return, via arg1, this record, # including continuation lines, but less the "JOB" token itself. setvar _str_arg1 word(_str_entry_parms) while str(setvar(!_str_arg1,ups(input())),2,4) <> "JOB " do endwhile # handle continuation lines and remove line numbers, if appropriate if setvar(_str_numbered,numeric(rht(!_str_arg1,8))) then setvar !_str_arg1 lft(!_str_arg1,len(!_str_arg1)-8) endif while rht(setvar(!_str_arg1,rtrim(!_str_arg1)),1) = '&' do # remove & and read next input record setvar !_str_arg1 lft(!_str_arg1,len(!_str_arg1)-1) + input() if _str_numbered then setvar !_str_arg1 lft(!_str_arg1,len(!_str_arg1)-8) endif endwhile # return all args right of "JOB", and fold all blanks. setvar !_str_arg1 repl(xword(!_str_arg1)," ","") return elseif _str_entry = "read_config" then # Arg 1 is the "[jobname,]user.acct" name from the job card. # Arg 2 is the *name* of the var to return the jobQ name if the acct name # matches an entry in the config file. # Input redirected to the jobQ config file. # Search config file until match or eof. Handle comments and blank lines. # A match can be on [jobname,]user.acct -- all wildcarded. setvar _str_arg1 word(_str_entry_parms," ") setvar _str_arg2 word(_str_entry_parms," ",2) setvar _str_eof finfo(hpstdin,'eof') # figure out if we have the optional jobname in arg1 setvar _str_jname '' setvar _str_ua word(_str_arg1) if pos(',',_str_arg1) > 0 then # have "jobname," in target job card setvar _str_jname _str_ua setvar _str_ua word(_str_arg1,,2) endif # read config file and find [jobname,]user.acct match (wildcards are ok) while setvar(_str_eof,_str_eof-1) >= 0 and & (setvar(_str_rec,ltrim(rtrim(input()))) = '' or & lft(_str_rec,1) = '#' or & not pmatch(ups(word(_str_rec,,-2)),_str_ua) or & (pos(',',_str_rec) > 0 and lft(_str_rec,2) <> '@,' and & not pmatch(ups(word(_str_rec)),_str_jname)) ) do # while stops on 1st user.acct match and if config file has a jobname # that is not simply '@' the job card must have a matching jobname too endwhile if _str_eof >= 0 then # [jobname,]user.acct match, return jobq name setvar !_str_arg2 word(_str_rec,,-1) endif return endif endif # Version History A.05 11/01/00 JV upshift parms so ;JOBQ= tests work for lowercasae "jobq=", and deal with JOB card spanning multiple lines. A.04 08/18/00 JV added code to ensure read access to the job file. A.03 07/28/00 JV fixed bug where numbered jobs were not parsed correctly. A.02 09/20/98 JV fixed bug where the args right of the stream file were not extracted correctly. A.01 08/31/98 JV Original version *** end of STREAM UDC ***