/* REXX */ /* run a USS program using BPXBATCH */ /* send messages back to TSO terminal */ parse arg shcmd /********************************************************************/ /* Free STDERR and STDOUT */ /********************************************************************/ msgs = msg('OFF') "FREE DDNAME(STDERR STDOUT)" address syscall 'getpid' unique=retval /* get the USS process id */ /********************************************************************/ /* Create temporary STDOUT file "/tmp/BPXSH."pid */ /********************************************************************/ "ALLOCATE FILE(STDOUT) PATH('/tmp/BPXPGM."unique"') ", "PATHOPTS(OWRONLY,OCREAT,OEXCL,OTRUNC) PATHMODE(SIRWXU)", "PATHDISP(DELETE,DELETE)" IF RC \= 0 Then Do msgs = msg(msgs) /* Allocate must have failed */ Say ' RUNPGM REXX exec failed to allocate STDOUT.' Say ' RUNPGM REXX exec did not run shell command ' shcmd RETURN END msgs = msg(msgs) /********************************************************************/ /* Invoke shell by calling BPXBATCH */ /********************************************************************/ /* If we are on V2R10 or higher, use BPXBATSL */ opsys = MVSVAR(SYSOPSYS) Parse Var opsys versn vv'.'mm'.'. fmid If versn = 'z/OS' | , (versn = 'OS/390' & vv >= 2 & mm > 8) then , "BPXBATSL PGM "shcmd else , "BPXBATCH PGM "shcmd IF RC > 255 Then DO Say ' RUNPGM Exit Status = ' RC/256 Say ' ' If RC = 32512 then , Say 'Program not found or not executable' END else , IF RC \= 0 Then DO Say ' RUNPGM RC = ' RC Say ' ' END IF (RC \= 254) & (RC \= 255) THEN DO /***************************************************************/ /* Display output from STDOUT and STDERR */ /***************************************************************/ "ALLOCATE FILE(oshout1) DA(*) LRECL(255) RECFM(F) REU" "Ocopy indd(STDOUT) outdd(oshout1) TEXT PATHOPTS(OVERRIDE)" "FREE DDNAME(oshout1)" END "FREE DDNAME(STDOUT)"