Rexx调用Unix命令展开JCL
Ricky
posted @ 2013年12月20日 13:34
in Other
, 2006 阅读
Rexx calls OMVS/USS command to expand JCL with parms
/** rexx vim: set ft=rexx: **/
/*author: Ricky Wu*/
/*function: expand JCL*/
arg jclsrc
jclsrc = strip(jclsrc,,"'")
isredit macro
uid=SYSVAR(SYSUID)
/*check parm*/
if length(jclsrc) = 0 then
do
address isredit "(dsname) = dataset"
address isredit "(mbr) = member"
jclsrc=dsname || "(" || mbr || ")"
end
/*check Unix System Services*/
if syscalls("ON") <> 0 then
do
say "Unix System Services not unavailable"
exit
end
address tso "oput "jclsrc" '/tmp/"uid"J'"
"ALLOC F(XXIN) DS('"jclsrc"') SHR REUSE"
"EXECIO * DISKR XXIN (FINIS STEM in."
"FREE F(XXIN)"
/* search from first line to end of file */
do recid = 4 to 6
startcol = 0
endcol = 0
startcol = pos("=",in.recid,20)
if startcol <> 0 then
endcol = pos(" ",in.recid,startcol)
/*parse lib and member*/
if startcol <> 0 & endcol <> 0 then
do
if recid = 4 then
do
len = endcol - startcol - 1
libFolder = substr(in.recid, startcol + 1, len)
/*check for multi lib*/
mulCol = pos('(', in.recid, startcol)
comCol = pos(',', in.recid, startcol)
if mulCol <> 0 then
do
len = comCol - mulCol - 1
libFolder = substr(in.recid, mulCol + 1, len)
end
end
else
do
/*get member name*/
len = endcol - startcol - 1
memName = substr(in.recid, startcol + 1, len)
cmd = 'cat "//'''libFolder"("memName")'"" "
cmd = cmd || ">> /tmp/ricky"
call bpxwunix cmd
end
end
else
do
if recid = 4 then
say "Error: = sign not found"
end
end
/*parse env var.*/
cmd = 'sed -e "\/\/\*/d;s/\/\/ *SET /\&/g;s/=''/\.=/g;s/=\&/\.=\&/g;s/'''
cmd = cmd || ' *$//g;s/ *$//g;" /tmp/ricky'
cmd = cmd || " > /tmp/parm;"
cmd = cmd || "awk -F= 'BEGIN{ while((getline<""/tmp/parm"")>0)"
cmd = cmd || "{ if ($0~/^\&ENV\./){a[$1]=($2);} }"
cmd = cmd || " close(""/tmp/parm"") } { for(x in a)"
cmd = cmd || "{ if ($0~x){ gsub(x, a[x]); } }"
cmd = cmd || " print$0 }' /tmp/parm > /tmp/env;"
cmd = cmd || "awk -F= 'BEGIN{ while((getline<""/tmp/env"")>0)"
cmd = cmd || "{ if ($0~/^\&.*\./){a[$1]=($2);} }"
cmd = cmd || " close(""/tmp/env"") } { for(x in a){ if ($0~x)"
cmd = cmd || "{ gsub(x, a[x]);} } print$0 }' /tmp/"
cmd = cmd || uid"J > /tmp/"uid"T"
call bpxwunix cmd
address tso "oget '/tmp/"uid"T' " || uid".TMP."uid"J"
cmd = "rm /tmp/ricky"
call bpxwunix cmd
"ISPEXEC VIEW DATASET('" || uid || ".TMP." || uid || "J') MACRO(RESET)"
2021年10月20日 19:49
The way it is coded as a great base for the users and the learners those who are freshers