/* REXX */ /* run a shell command 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/BPXSH."unique"') ", "PATHOPTS(OWRONLY,OCREAT,OEXCL,OTRUNC) PATHMODE(SIRWXU)", "PATHDISP(DELETE,DELETE)" IF RC ^= 0 Then Do msgs = msg(msgs) /* Allocate failed */ Say ' Unable to allocate STDOUT.' Say ' Shell command ' shcmd ' did not run' RETURN END msgs = msg(msgs) /********************************************************************/ /* Invoke shell by calling BPXBATCH */ /********************************************************************/ "BPXBATCH SH "shcmd IF RC ^= 0 Then DO Say ' SHELL RC = ' RC Say ' ' END IF RC > 255 Then DO Say ' SHELL Exit Status = ' RC/256 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)"