Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Rexx command to execute MVS console commands

4,454 views
Skip to first unread message

Victor Zhang

unread,
Oct 18, 2010, 8:31:51 AM10/18/10
to
Hi,
I want to write a rexx program to execute several mvs commands serially.
I have tested following:
/*REXX*/
"CONSOLE ACTIVATE"
"CONSOLE SYSCMD(D U,,,A20,1) CART('DA01')"
MCODE=GETMSG('RESMSG1.','SOL','DA01',,120)
IF RESMSG1.0 = 0 THEN DO
SAY 'NO MESSAGE RETURNED'
RETURN
END
ELSE
DO I=1 TO RESMSG1.0
SAY RESMSG1.I
END

It worked, but the problem is CONSOLE SYSCMD(mvscmd) must be code with exact
mvs command, ie. mvscmd must be any specific mvs command, it can't be
substituted by a string variable.
What I want to do is:
read an input file which contains several mvs cmd.
then run CONSOLE SYSCMD(syscmd) where syscmd is the cmd I read from input file
then display cmd output.

Anyone has the experience?

Regards
Victor

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to list...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Veilleux, Jon L

unread,
Oct 18, 2010, 8:53:46 AM10/18/10
to
You need to unquote the command. Here's an example that should work.
/*REXX*/
cmd.1='d a,l'
cmd.2='d t'
cmd.3='d d,t'
"CONSOLE ACTIVATE"
do x=1 to 3
"CONSOLE SYSCMD("cmd.x")"
MCODE=GETMSG('RESMSG1.','SOL',,,60)
IF RESMSG1.0 = 0 THEN DO
SAY 'NO MESSAGE RETURNED'
RETURN
END
ELSE
DO I=1 TO RESMSG1.0
SAY RESMSG1.I
END
resmsg1.0=0
end
"CONSOLE DEACTIVATE"
exit

Anyone has the experience?

Regards
Victor

This e-mail may contain confidential or privileged information. If
you think you have received this e-mail in error, please advise the
sender by reply e-mail and then delete this e-mail immediately.
Thank you. Aetna

Charles Mills

unread,
Oct 18, 2010, 8:57:41 AM10/18/10
to
I have never used Rexx CONSOLE but I would think

Cmd = "D U,,,A20,1"
"CONSOLE SYSCMD(" || Cmd || ") CART('DA01')"

Would work no differently than what you have below.

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-...@bama.ua.edu] On Behalf
Of Victor Zhang
Sent: Monday, October 18, 2010 5:31 AM
To: IBM-...@bama.ua.edu
Subject: Rexx command to execute MVS console commands

----------------------------------------------------------------------

Veilleux, Jon L

unread,
Oct 18, 2010, 9:16:25 AM10/18/10
to
You might want to add 'cmd.x =strip(cmd.x )' to get rid of any extraneous blanks.

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-...@bama.ua.edu] On Behalf Of Veilleux, Jon L
Sent: Monday, October 18, 2010 8:53 AM
To: IBM-...@bama.ua.edu
Subject: Re: Rexx command to execute MVS console commands

You need to unquote the command. Here's an example that should work.
/*REXX*/
cmd.1='d a,l'
cmd.2='d t'
cmd.3='d d,t'
"CONSOLE ACTIVATE"
do x=1 to 3

cmd.x =strip(cmd.x )

Biao Sun

unread,
Oct 18, 2010, 9:23:34 AM10/18/10
to
Try the INTERPRET command:

_cmd_ = "D U,,,A20,1"
_mvscmd_ = "CONSOLE SYSCMD(" !! _cmd_ !! " CART('DA01')"
Interpret _mvscmd_

I haven't tried it myself.

-----Urspr�ngliche Nachricht-----
Von: IBM Mainframe Discussion List [mailto:IBM-...@bama.ua.edu] Im Auftrag von Victor Zhang
Gesendet: Montag, 18. Oktober 2010 14:31
An: IBM-...@bama.ua.edu
Betreff: Rexx command to execute MVS console commands

Anyone has the experience?

Regards
Victor

__________________________________________________________________________________________________________________________________________
Atos Origin GmbH, Theodor-Althoff-Stra�e 47, D-45133 Essen, Postfach 100 123, D-45001 Essen
Telefon: +49 201 4305 0, Fax: +49 201 4305 689095, www.atosorigin.de
ING Bank AG, Frankfurt/Main: Konto 001 014 0937, BLZ 500 210 00, Swift / BIC INGBDEFF, IBAN DE74 5002 1000 0010 1409 37
Gesch�ftsf�hrer: Winfried Holz, Vorsitzender des Aufsichtsrats: Peter Hollfelder, Handelsregister Essen HRB 19354, Ust.-ID.-Nr.: DE147861238
___________________________________________________________________________________________________________________________________________

zMan

unread,
Oct 18, 2010, 9:30:23 AM10/18/10
to
On Mon, Oct 18, 2010 at 9:12 AM, Biao Sun <Biao...@atosorigin.com> wrote:
> Try the INTERPRET command:

Why? What's the problem you're trying to solve by doing so? Without (I
hope) restarting the decades-old INTERPRET wars, it's only rarely
necessary, and certainly not in this case.
--
zMan -- "I've got a mainframe and I'm not afraid to use it"

Bruce Schaefer

unread,
Oct 18, 2010, 7:25:10 PM10/18/10
to
Here is code and sample JCL that I use:
/* rexx
| Issue MVS console commands and capture
responses.
|
| This routine can be called as a TSO/Rexx command or as an
ISPF
| edit macro. When called as an edit macro, S or SS line
commands
| can be used to limit selected lines.
|
| Appropriate security access is required.
|
| /* in columns 1-2 is a comment. All other values are passed
to
| the MVS command processor. */
|
| For JES2 commands, this routine looks for ',L=' in the
command
| and if not found will append ',L=Z' to the command so that
all
| output will be captured.
| Note: If you use the L= parameter or any of the REDIRect
commands
| to redirect output to any out-of-line area, the output is issued
| as a multi-line WTO (write to operator) response to the
specified
| area. The first line is the $HASP636 control line.
|
*/
/*---------------------------------------------------------------------
| Set user defaults
------------------------------------------------------------------- */
/*trace L*/
Parse Source . callmode exec_name .
o_workunit = "SYSDA"
o_temphlq = Sysvar(Sysuid)".SPFTEMP9" /* HLQ for user temp ds
*/
o_cmds = "COMMANDS" /* Use this ddname to input commands
*/
o_dsn = "" /* Use another dataset name? */
o_delwrk = 1 /* Delete work dataset and allocate new one
*/
o_save = "DELETE" /* Save temporary output dataset?
*/
o_outdd = 0 /* Dynamically create output dataset */
o_ios = 1 /* Do generate IOS info */
o_noh = 0 /* Don't suppress header lines */
o_maxtime = 5 /* */
num_lines = 0
o_debug = 0 /* */
isredit = 0
If callmode = 'FUNCTION' Then
Do
function = 1
say arg() arg(1)
Return 'Function mode is not supported as yet.'
End
Else
Do
function = 0
If Sysvar("SYSISPF") = "ACTIVE" Then
Address ISREDIT "MACRO (parms)
NOPROCESS"
If rc = 0 Then isredit = 1
Else parms = Arg(1)
End
/*
| Security check
*/
If Substr(MVSVAR('SYSNAME'),1,3) <> "TOL" Then
If FTBRCFX('dataset(USER.SYSTEM.SUPPORT),attr(a)') <> 0
Then,
Signal INVALID_CALLER
/*
| Process parms
*/
Do i = 1 To Words(parms)
this = Translate(Strip(Word(parms,i))) /* uppercase option
*/
that = Translate(Strip(Word(parms,i+1))) /* uppercase option
*/
Select
When this == "CMDS"|,
this == "COMMANDS" Then Do
If that == "" Then Do
Say "Missing ddname, terminating"
Exit 12
End
o_cmds = that
i = i + 1
End
When this == "DSN"|,
this == "DSNAME" Then Do
If that == "" Then Do
Say "Missing dataset name, terminating"
Exit 12
End
o_dsn = that
o_delwrk = 0 /* do not delete existing dsn */
i = i + 1
End
When this == "REPLACE"|,
this == "NODELETE" Then o_delwrk = 0
When this == "DEBUG" Then o_debug = 1
When this == "NOIOS" Then o_ios = 0
When this == "NOH" Then o_noh = 1
When this == "IOS" Then o_ios = 1
When this == "OUTDD" Then Do
If that == "" Then Do
Say "Missing ddname, terminating..."
Exit 12
End
o_outdd = that
o_delwrk = 0 /* do not delete existing dsn */
i = i + 1
End
When this == "MAXTIME" Then Do
If that == ""|,
^Datatype(that,'N') Then Do
Say "Invalid time value, terminating..."
Exit 12
End
o_maxtime = that
i = i + 1
End
When this == "SAVE" Then o_save = ""
Otherwise
Say "Ignoring Invalid option:" this
End
End
/*---------------------------------------------------------------------
| Did everything parse out ok?
------------------------------------------------------------------- */
If o_noh Then o_ios = 0 /* noh forces noios option */
If Sysvar("SYSISPF") ^= "ACTIVE" Then
"EXECIO * DISKR " o_cmds "(STEM commands.
FINIS"
Else
Do
/*---------------------------------------------------------------------
| Process the whole dataset or just the lines selected
------------------------------------------------------------------- */
Address ISREDIT
'PROCESS RANGE S'
Select
When rc = 0 Then Do
'(CMD) = RANGE_CMD' /* Get the command */
'(LINE1) = LINENUM .ZFRANGE' /* Get first in range */
'(LINE2) = LINENUM .ZLRANGE' /* Get last in range */
End
When rc <= 4 Then Do /* No S or SS entered, use entire file
*/
'(CMD) = RANGE_CMD' /* Get the command */
'(LINE1) = LINENUM .ZFIRST' /* Get first in range */
'(LINE2) = LINENUM .ZLAST' /* Get last in range */
End
Otherwise /* Line command conflict - Edit will create message
*/
Exit 12
End
Do i = line1 To line2
'(LINEVAL) = LINE' i
num_lines = num_lines + 1
commands.num_lines = Strip(lineval)
End
commands.0 = num_lines
Address TSO
End

If o_outdd <> 0 Then
Do
lpfwrkf_dd = o_outdd
o_outdd = 1
Call Bpxwdyn "info fi("lpfwrkf_dd") inrtdsn(o_dsn)"
If result > 0 Then
Do
Say ' Output DDname' lpfwrkf_dd 'was not found.
Terminating...'
Exit 12
End
End
Else
Do /* Allocate work file */
If Sysvar("SYSISPF") ^= "ACTIVE" &,
o_dsn = "" Then Signal invalid_outdd
lpfwrkf_ran = Random()
lpfwrkf_dd = "LPF"lpfwrkf_ran
/* code to handle system symbols within DSN */
If Pos('&',o_dsn) > 0 Then
Do Until Pos('&',o_dsn) = 0
Do
f_pos = Pos('&',o_dsn)
Do l_pos=f_pos+1 For 8
If Datatype(Substr(o_dsn,l_pos,1),'U') |,
Datatype(Substr(o_dsn,l_pos,1),'N') |,
Pos(Substr(o_dsn,l_pos,1),'@#$') > 0 Then Iterate
Else Leave
End
If Length(Mvsvar('Symdef',,
Substr(o_dsn,f_pos+1,l_pos-f_pos-1),
)) > 0 Then
Do
/* add code to handle &sysname.X correctly */
If Substr(o_dsn,l_pos,1) = '.' Then
o_dsn = Substr(o_dsn,1,f_pos-1)||,
Mvsvar('Symdef',Substr(o_dsn,f_pos+1,l_pos-f_pos-1))
||,
Substr(o_dsn,l_pos+1,Length(o_dsn)-l_pos)
Else
o_dsn = Substr(o_dsn,1,f_pos-1)||,
Mvsvar('Symdef',Substr(o_dsn,f_pos+1,l_pos-f_pos-1))
||,
Substr(o_dsn,l_pos,Length(o_dsn)-l_pos+1)
End
Else
Do
Say 'Invalid symbol; terminating...'
Exit
End
End
End

If o_dsn <> "" Then lpfwrkf_dsn = o_dsn
Else lpfwrkf_dsn
= "'"o_temphlq"."exec_name".#"lpfwrkf_ran"'"
If o_delwrk == 1 Then
Do
x = Outtrap("XMSG.","*")
"DELETE "lpfwrkf_dsn
x = Outtrap("off")
"ALLOCATE FILE("lpfwrkf_dd") DA("lpfwrkf_dsn")" ,
"UNIT("o_workunit") NEW" o_save "REUSE SPACE(30 30)
TRACKS" ,
"LRECL(80) BLKSIZE(0) RECFM(F B)"
arc = rc
End
Else
Do
"ALLOCATE FILE("lpfwrkf_dd") DA("lpfwrkf_dsn") SHR"
arc = rc
End
If arc <> 0 Then
Do
Say "Allocation of work dataset: "lpfwrkf_dsn "failed," ,
"terminating..."
Exit 12
End
End
Newstack
/*
| Write Header
*/
header0 = '*-----------------------------------------------------------------*'
comment = '*'
If ^o_noh Then
Do
Queue header0
Queue comment 'Generated by the' exec_name,
'rexx routine on' Date('O') 'at' Time()
Queue comment ' SYSNAME:' Mvsvar(Sysname) ' User:' Sysvar
(Sysuid),
' Jobname:' Mvsvar('SYMDEF','JOBNAME')
Queue comment ' Command:' exec_name
parms
Queue comment
End
x = outtrap("consprof.","*")
"CONSPROF"
x = outtrap("off")
If rc ^= 0 Then Signal finished
Parse Value consprof.1 With . ' SOLDISPLAY('soldisplay,
') SOLNUM('solnum') ' .
If soldisplay = 'YES' Then "CONSPROF SOLDISPLAY
(NO)"
If Sysvar('Sysenv') = 'BACK' Then
"CONSOLE ACTIVATE NAME("Mvsvar
('SYMDEF',Jobname)")"
Else
"CONSOLE ACTIVATE NAME("Sysvar(Sysuid)||,
Substr(Mvsvar(Sysname),Length(Mvsvar
(Sysname)),1)")"
If rc ^= 0 Then Signal finished
If o_ios Then
Do
command = 'D IOS,CONFIG'
Queue comment command
Call IssueCmd
End
If ^o_noh Then Queue header0

Do a=1 to commands.0
command = commands.a
If Substr(command,1,2) = '/*' Then
Do
Say ' Command skipped:' command
Iterate
End
If Pos('$',command) > 0 Then
Do
If Pos(',L=',command) = 0 &,
Pos(',l=',command) = 0 Then
command = command',L=Z'
End
If ^o_noh Then Queue comment command
Call IssueCmd
If o_debug Then,
Queue comment getmsg.0 'getmsg calls were made for previous
command.'
End

FINISHED:
"CONSOLE DEACT"
If soldisplay = 'YES' Then "CONSPROF SOLDISPLAY
(YES)"
Queue '' /* indicate end of file */
"EXECIO * DISKW "lpfwrkf_dd" (FINIS"
"Delstack"
/* At this point lpfwrkf_dsn contains the command responses!
*/
If Sysvar("SYSISPF") = "ACTIVE" Then
Address Ispexec "VIEW DATASET("lpfwrkf_dsn")"
If ^o_outdd Then "FREE FILE("lpfwrkf_dd")"
If o_save = "" Then Say "DSN="lpfwrkf_dsn "has been
saved"
Exit 0

ISSUECMD:
/*"CONSOLE SYSCMD("command")" */
Address CONSOLE command
/*r = Getmsg('out.',,,,'30') */
getmsg.0 = 0
Do until r > 0
getmsg.0 = getmsg.0 + 1
r = Getmsg('out.',,,,o_maxtime)
If r = 0 Then
Do x=1 to out.0
Queue /*comment*/out.x
End
Else
If getmsg.0 = 1 Then
Do
Queue comment 'Error processing command:'
command
Queue comment ' RC from GETMSG():' r
Signal Finished
End
End
Return r
INVALID_CALLER:
Say "Caller is not authorized to use this routine in this
environment."
Exit 12
INVALID_OUTDD:
Say "OUTDD ddname or DSN dsname is required for non-ISPF
environments."
Exit 12
INVALID_SYNTAX:
Do 4;Say;End
Say "No options requested, syntax is:"
Say " " exec_name "options " ;Say
Say " Options are:"
Say " DSN|DSNAME dsname|dsname
(member) "
Say " to direct output to specific dataset."
Say " IOS|NOIOS to include response from D IOS,CONFIG
command."
Say " NOH to suppress headers; and forces NOIOS"
Say " OUTDD ddname used to direct output to specific
dd."
Say " SAVE will not delete temporary dataset."
Say " MAXTIME time the amount of time, in seconds, that
GETMSG"
Say " should wait. See help on Getmsg for more info."
Say
Say " DSN can contain system symbols, such as
&SYSCLONE"
Say " OUTDD ddname or DSN dsname is required for non-ISPF
environments."
Say " IOS is a default."
Say " SAVE only applies to TSO environment."
Exit 12
/*

//JS010 EXEC PGM=IKJEFT01
//* PARM='%MVSCMDS OUTDD SYSOUT NOIOS'
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//DEV1AO DD SYSOUT=*
//SYSPROC DD DISP=SHR,DSN=my.ISPF.CLIST
//SYSTSIN DD *
%MVSCMDS COMMANDS DEV1A OUTDD DEV1AO NOH
/*
//DEV1A DD *
RO test,D SYMBOLS
/*
//

Victor Zhang

unread,
Oct 19, 2010, 2:21:38 AM10/19/10
to
Thanks for your reply, now the problem solves by unquoting command from
console command.
But I have a new problem, when I use following jcl to execute the rexx:
//MVSJCL JOB (ACCNT#),
// CLASS=T,
// MSGCLASS=X,
// MSGLEVEL=(1,1),
// NOTIFY=&SYSUID,
// TIME=1440
//PROCVTV EXEC PGM=IKJEFT01,REGION=0M
//SYSEXEC DD DISP=SHR,DSN=userid.REXX.EXEC
//SYSPRINT DD SYSOUT=*
//INFILE DD *
D A,L
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
%REXXMVS
following error messages appeared:
IKJ55303I THE CONSOLE COMMAND HAS TERMINATED.+
IKJ55303I AN ERROR OCCURRED DURING CONSOLE INITIALIZATION. THE MCSOPER
RETURN CODE WAS X'00000004' AND THE REASON CODE WAS X'00000000'.

Please provide me a sample jcl to run rexx console program.

Thanks
Victor

Veilleux, Jon L

unread,
Oct 19, 2010, 7:07:37 AM10/19/10
to
The PARM (command) goes on the same line as the rexx exec.

//MVSJCL JOB (ACCNT#),
// CLASS=T,
// MSGCLASS=X,
// MSGLEVEL=(1,1),
// NOTIFY=&SYSUID,
// TIME=1440
//PROCVTV EXEC PGM=IKJEFT01,REGION=0M
//SYSEXEC DD DISP=SHR,DSN=userid.REXX.EXEC
//SYSPRINT DD SYSOUT=*

//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *

%REXXMVS D A,L

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-...@bama.ua.edu] On Behalf Of Victor Zhang
Sent: Tuesday, October 19, 2010 2:20 AM
To: IBM-...@bama.ua.edu

Thanks
Victor

This e-mail may contain confidential or privileged information. If
you think you have received this e-mail in error, please advise the
sender by reply e-mail and then delete this e-mail immediately.
Thank you. Aetna

----------------------------------------------------------------------

Shmuel Metz , Seymour J.

unread,
Oct 31, 2010, 8:48:09 AM10/31/10
to
In
<227CD15431192D4AAC56...@DEESX001.deuser.de.intra>,
on 10/18/2010

at 03:12 PM, Biao Sun <Biao...@ATOSORIGIN.COM> said:

>Try the INTERPRET command:

Why? It's almost always the wrong answer.

>_cmd_ = "D U,,,A20,1"
>_mvscmd_ = "CONSOLE SYSCMD(" !! _cmd_ !! " CART('DA01')" Interpret
>_mvscmd_

It's not my dog.

>I haven't tried it myself.

Try it ;-)

--
Shmuel (Seymour J.) Metz, SysProg and JOAT
ISO position; see <http://patriot.net/~shmuel/resume/brief.html>
We don't care. We don't have to care, we're Congress.
(S877: The Shut up and Eat Your spam act of 2003)

0 new messages