here is a hopefully illustrative example:

//SYMTEST JOB (),'KIRK',MSGCLASS=H
//  EXPORT SYMLIST=(MYSYM)
//  SET MYSYM='/some/useful/path/name'
//SHELL EXEC PGM=COZBATCH # a better BPXBATCH
//STDIN DD   *
set -o pipecurrent  # required for: | read ...

# get the current JES symbols as shell variables
#  ... maybe use these to control the script?
jessym -s | . /dev/fd0
echo "MYSYM=$MYSYM"

# set some new JES symbols
jessym -c DSN1=MY.FOO.IN DSN2=MY.FOO.OUT

# submit a job, passing all JES symbols, and get the jobid
fromdsn "//kirk.sample.jcl(br14)" \
  | todsn -x "symlist(*)" //intrdr \
  | read x jobid x   # "JOB JOBnnnn submitted"
echo "JOB $jobid submitted"

# wait for the job to run
i=0
while [[ i -le 20 ]]; do
  lsjes -t -i $jobid | read x jobname x phase x compl
  # lsjes outputs a line like:
  #    JOBnnnn JOBNAME USERID PHASE CLASS RC=XXXX
  if [[ "$phase" == "OUTPUT" ]]; then
    echo "JOB $jobname($jobid) completed $compl"
    # grab one of the job's spool files and print it to stdout
    # ... might also want to grep/sed/process it
    fromdsn -JES.$jobid.JESJCL
    break
  fi
  let i=i+1
  sleep 2
done
//

Here's the job output written to DD:SYSOUT  (the merged stdout/stderr from
the shell):

MYSYM=/some/useful/path/name
fromdsn(KIRK.SAMPLE.JCL(BR14))[N]: 3 records/240 bytes read; 71 bytes
written in 0 milliseconds.
todsn(INTRDR)[N]: 71 bytes read; 3 records/240 bytes written in 0.885
seconds (80.226 Bytes/sec).
JOB JOB00502 submitted

JOB BR14(JOB00502) completed RC=0000

fromdsn(KIRK.BR14.JOB00502.D0000003.JESJCL)[N]: 10 records/835 bytes read;
845 bytes written in 0 milliseconds.
        1 //BR14 JOB (),'WOLF',MSGCLASS=H,NOTIFY=&SYSUID.
      JOB00502
          IEFC653I SUBSTITUTION JCL - (),'WOLF',MSGCLASS=H,NOTIFY=G1JAVA1

        2 // SET DSN1=MY.FOO.IN                                GENERATED
STATEMENT
        3 //DSN1     EXPORT EXPSET=MY.FOO.IN                   GENERATED
STATEMENT
        4 // SET DSN2=MY.FOO.OUT                               GENERATED
STATEMENT
        5 //DSN2     EXPORT EXPSET=MY.FOO.OUT                  GENERATED
STATEMENT
        6 // SET MYSYM=/some/useful/path/name                  GENERATED
STATEMENT
        7 //MYSYM    EXPORT EXPSET=/some/useful/path/name      GENERATED
STATEMENT
        8 // EXEC PGM=IEFBR14

        9 //

CoZBatch[I]: returning rc=exitcode=0


Notice the generated statements above; the JES symbols passed into the
submitted job


Kirk Wolf
Dovetailed Technologies
http://dovetail.com

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to