#! /bin/awk -f # #------------------------------------------------------------------------------ # This awk script reads in an IDCAMS LISTCAT listing and generates IEHPROGM # UNCATLG and SCRATCH statements for datasets on matching VOLSER volumes. # !!! set volume/unit values in BEGIN before executing !!! # # Syntax: awk -f scratch.awk [listcat output file] > [generated jcl file] #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ # set arrays of volume[] & unit[] to volume serial number(s) to select and # generate JCL for IEHPROGM #------------------------------------------------------------------------------ BEGIN { volume[1] = "SMP001"; unit[1] = "3350"; volume[2] = "WORK02"; unit[2] = "3350"; print "//IEHPROGM JOB CLASS=A,MSGLEVEL=(1,1)" print "//* GENERATED BY SCRATCH.AWK" print "//IEHPROGM EXEC PGM=IEHPROGM" print "//SYSPRINT DD SYSOUT=A" for (entry in volume) { ddn++; dds = "//DD" ddn dds = dds " DD UNIT=" unit[entry] dds = dds ",VOL=SER=" volume[entry] dds = dds ",DISP=OLD" print dds } # for print "//SYSIN DD *" } # BEGIN # #------------------------------------------------------------------------------ # save dataset name #------------------------------------------------------------------------------ $1 == "NONVSAM" { dsn = $3 } # #------------------------------------------------------------------------------ # process volume information against array of volumes to select #------------------------------------------------------------------------------ substr($1,1,6) == "VOLSER" { for (entry in volume) { if (volume[entry] == substr($1,19,6)) { print " UNCATLG DSNAME=" dsn; ss = " SCRATCH DSNAME=" dsn ss = ss ",VOL=" unit[entry] "=" volume[entry] ss = ss ",PURGE" print ss } # if } # for } # substr($1,1,6) == "VOLSER" # #------------------------------------------------------------------------------ # terminate generated jobstream #------------------------------------------------------------------------------ END { print "/*" print "//" } # END