Let's say I wanted to get into my Unix account on USS (OMVS) and issue a
'pwd' command, and display the output.
I tried:
address TSO
"OMVS"
"pwd"
but I failed on the OMVS command:
"The OMVS command failed because the display screen size is not supported.
The screen size must be at least 12 by 40 but less than 16384 bytes total.
The alternate screen size is 0 by 0 (0 bytes)."
Not surprising, but is there some way to do this? I know I can create a
shell script in USS, and then run it under MVS batch by executing BPXBATCH,
but I really need to run the Unix commands under the control of REXX running
in batch. I suppose I could create the shell script, TSO ALLOC STDIN and
STDOUT and then call BPXBATCH, but that seems awfully round-about. Is there
a more direct way?
Jeff
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX
Here's the simplest example I have:
//REXXOEX JOB (,R214),POITRAS,TIME=(0,10),CLASS=A,
// MSGCLASS=A
/*JOBPARM FETCH
//UPDATE EXEC PGM=IRXJCL,DYNAMNBR=100,REGION=4096K,
// PARM='OEREXX'
//SYSEXEC DD DSN=SASDTP.REXX,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//
with rexx(oerexx) containing:
/* rexx */
if syscalls('ON') > 3 then
do
say 'Unable to establish the SYSCALL environment'
return
end
address syscall
"getcwd cwd"
say 'current directory is'
cwd
Jeff Byrum wrote:
>
> Can I issue OMVS (UNIX) commands from a REXX exec running as a batch job
> under MVS (z/OS)?
>
> Let's say I wanted to get into my Unix account on USS (OMVS) and issue a
> 'pwd' command, and display the output.
>
> I tried:
>
> address TSO
> "OMVS"
> "pwd"
>
> but I failed on the OMVS command:
>
> "The OMVS command failed because the display screen size is not supported.
> The screen size must be at least 12 by 40 but less than 16384 bytes total.
> The alternate screen size is 0 by 0 (0 bytes)."
>
> Not surprising, but is there some way to do this? I know I can create a
> shell script in USS, and then run it under MVS batch by executing BPXBATCH,
> but I really need to run the Unix commands under the control of REXX running
> in batch. I suppose I could create the shell script, TSO ALLOC STDIN and
> STDOUT and then call BPXBATCH, but that seems awfully round-about. Is there
> a more direct way?
>
> Jeff
--
Don Poitras - EST Development - SAS Institute Inc. - SAS Campus Drive
mailto:sas...@sas.com (919)531-5637 Fax:677-4444 Cary, NC 27513
I'm not sure why that wrapped... Last line should be:
say 'current directory is' cwd
--
Here are two quick and dirty little examples of using BPXBATCH from REXX.
BPXCMD will put the command results in a stem and say the results. BPXBRWSE
will use OBROWSE to browse the results. In both cases the only parameter is the
USS command you want to execute. I also have a more elegant USSCMD EXEC that
will prompt you through the process, does better error handling and better
reporting (recognizes command failures and will show the contents of STDERR).
Another tool I wrote is an edit macro called @USSCMD that will take your current
edit session, copy the contents to an HFS /tmp file then cat the tmp file
into any USS command pipeline you want. So, you can use Unix commands like grep,
sort, uniq, wc, whatever... Under ISPF, grep is mildly useful due to the
inability of ISPF to use some of the special Unix meta characters (specifically
the '^'). Send me a note off-list if you want copies of these two EXECs.
/* REXX BPXCMD */
parse arg usscmd
parse upper source . . execname .
usstime = time('s')
stdout = '/tmp/'||userid()||'-'||execname||'-stdout-'||usstime
stderr = '/tmp/'||userid()||'-'||execname||'-stderr-'||usstime
"ALLOC F(STDOUT) PATH('"stdout"') PATHMODE(SIRWXU)",
"PATHOPTS(OWRONLY,OCREAT,OTRUNC)"
"ALLOC F(STDERR) PATH('"stderr"') PATHMODE(SIRWXU)",
"PATHOPTS(OWRONLY,OCREAT,OTRUNC)"
"BPXBATCH SH" usscmd
BPXRC = RC / 256
if BPXRC <> 0 then say usscmd 'BPXRC='RC
"ALLOC F(CMDOUT) PATH('"stdout"') FILEDATA(TEXT)",
"PATHOPTS(ORDONLY) LRECL(136) BLKSIZE(1364) PATHDISP(DELETE,DELETE)"
"EXECIO * DISKR CMDOUT (STEM CMDOUT. FINIS"
do i=1 to cmdout.0
say strip(cmdout.i)
end
"BPXBATCH SH rm" stderr
"FREE F(STDOUT STDERR CMDOUT)"
exit(BPXRC)
/* REXX - BPXBRWSE */
parse arg usscmd
parse upper source . . execname . execdsn . . execenv .
usstime = time('s')
stdout = '/tmp/'||userid()||'-'||execname||'-stdout-'||usstime
stderr = '/tmp/'||userid()||'-'||execname||'-stderr-'||usstime
"ALLOC F(STDOUT) PATH('"stdout"') PATHMODE(SIRWXU)",
"PATHOPTS(OWRONLY,OCREAT,OTRUNC)"
"ALLOC F(STDERR) PATH('"stderr"') PATHMODE(SIRWXU)",
"PATHOPTS(OWRONLY,OCREAT,OTRUNC)"
"BPXBATCH SH" usscmd
BPXRC = RC / 256
if BPXRC <> 0 then say 'BPXRC='RC
"OBROWSE" stdout
"FREE F(STDOUT STDERR)"
"BPXBATCH SH rm" stdout
"BPXBATCH SH rm" stderr
exit(BPXRC)
Hope This Helps,
Robert Zenuk
robz...@aol.com
Thanks very much for your usual excellent examples!
Just FYI, I have also just discovered the "bpxwunix" command, available in
z/OS 1.4, which (like syscalls) will work outside the USS environment, say
in TSO/E. Here's a generic example from a REXX program that runs in MVS
batch:
call bpxwunix 'xxxxx yy zz',,out.
Do outx = 1 to OUT.0
Say 'OUT.'outx '=' OUT.outx
End outx
where "xxxxx yy zz" is any USS command. For example, you could code:
call bpxwunix 'ls -l',,out.
and the Do loop will display the resulting directory list. "bpxwunix" also
allows you to specify stdin, stdout and stderr as compound variables
(stems).
For more information on bpxwunix, see "z/OS V1R4.0 Using REXX and z/OS UNIX
System Services"
Thanks again for your help...
Jeff
> -----Original Message-----
> From: Robert Zenuk [mailto:Robz...@AOL.COM]
> Sent: Wednesday, August 06, 2003 2:05 PM
> To: TSO-...@VM.MARIST.EDU
> Subject: Re: Issuing OMVS Command from REXX?
>
>
> Aside from SYSCALL environment (very nice for detailed work),
> you can also
> use BPXBATCH directly from a REXX EXEC.
>
<snip>
> call bpxwunix 'xxxxx yy zz',,out.
>
> Do outx = 1 to OUT.0
> Say 'OUT.'outx '=' OUT.outx
> End outx
Thanks! I have been using BPXWUNIX for about a year and did not know about
this stem feature. Here is my quick and dirty example, I like it! I'll have
to look at the z/OS 1.4 manuals and read up on this (we just went to z/OS 1.3).
/* REXX - BPXWUNIX */
parse arg usscmd
call bpxwunix usscmd,,out.
do i=1 to out.0
say strip(out.i)
end
Prior to z/OS 1.4, BPXWUNIX was an add-on from the Tools and Toys page and
did not come with much doc (or I did not read it carefully enough). The big
reason I have used BPXWUNIX was the ease of use in JCL. BPXBATCH works, but
BPXWUNIX allows STDOUT and STDERR to actually go to "normal" DD statements and
ultimately use SYSOUT instead of USS files. Gil has pointed this out on the list
several times and that's how I found out about it. I wrote a little wrapper
for BPXWUNIX called BPXSPOOL to simplify the JCL setup and the review of the
results by Production Control folks.
/* BPXSPOOL - redirects STDOUT and STDERR to the JES2 Spool from JCL */
parse arg command
EXITRC = BPXWUNIX(command,'DD:stdin','DD:stdout','DD:stderr','0')
exit(EXITRC)
The JCL for BPXSPOOL:
//MYJOB JOB ......
//*******************************************************************
//* EXECUTE A USS COMMAND USING BPXSPOOL *
//*******************************************************************
//USSCMD EXEC PGM=IKJEFT01,PARM='BPXSPOOL ls -l'
//SYSEXEC DD DSN=exec.pds,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD DUMMY
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDIN DD DUMMY
Hope This Helps,
Robert Zenuk
robz...@aol.com
----------------------------------------------------------------------