IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Running REXX through JOB


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Patrick Bacelar

New User


Joined: 05 Sep 2022
Posts: 15
Location: Brazil

PostPosted: Wed Mar 06, 2024 10:39 pm
Reply with quote

Hello everyone, I'm creating a job that will run once a week and it basically needs to issue commands in JES2. These are basic commands such as "P OPCC" or "S OPCC" to terminate and start the task.
I have a REXX script that does this, and I can execute it directly or through screen 6 of IPSF:

EX 'MFTD.REXX(STOPOPCC)'

It works fine this way, but when I try to execute it through a job, it simply doesn't work...


Code:
/* REXX */                                     
RCODE = ISFCALLS('ON')                         
"ALLOC F(ISFTRACE) DA('MFTD.SDSF.TRACE') SHR"
 ADDRESS SDSF "ISFEXEC '/S OPCT'"               
"FREE F(ISFTRACE)"                             
CALL ISFCALLS('OFF')                           
RETURN RCODE 



Code:
//STOPOPCC JOB (),'STOP OPCC',NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1),
// MSGCLASS=X               
//*
//STEP0001  EXEC PGM=IKJEFT01   
//SYSEXEC   DD DSN=MFTD.REXX,DISP=SHR
//SYSTSPRT  DD   SYSOUT=A       
//SYSTSIN   DD   *               
  EXEC 'MFTD.REXX(STOPOPCC)'
/*                               
//



Job ended with RC 00 but nothing happens with the task...
I appreciate it if anyone has any suggestions.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2030
Location: USA

PostPosted: Wed Mar 06, 2024 10:46 pm
Reply with quote

Add "trace r" or "trace i" to your REXX procedure.

Is it the first REXX code you've ever tried?
The coded logic looks extremely strange... 824.gif
Back to top
View user's profile Send private message
Patrick Bacelar

New User


Joined: 05 Sep 2022
Posts: 15
Location: Brazil

PostPosted: Thu Mar 07, 2024 12:53 am
Reply with quote

Sorry, I'm not very experienced with REXX.

I updated the REXX script and submitted again the job, now I got this:


EXEC 'IBMUSER.REXX(STOPOPCC)'
3 *-* RCODE = ISFCALLS('ON')
>>> "0"
4 *-* "ALLOC F(ISFTRACE) DA('IBMUSER.SDSF.TRACE') SHR"
>>> "ALLOC F(ISFTRACE) DA('IBMUSER.SDSF.TRACE') SHR"
5 *-* ADDRESS SDSF "ISFEXEC '/S OPCT'"
>>> "ISFEXEC '/S OPCT'"
+++ RC(8) +++
6 *-* "FREE F(ISFTRACE)"
>>> "FREE F(ISFTRACE)"
7 *-* CALL ISFCALLS('OFF')
>>> "OFF"
>>> "0"
8 *-* RETURN RCODE
>>> "0"
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Thu Mar 07, 2024 1:40 am
Reply with quote

I think that by now you should use the ISFSLASH command, i.e.
Code:
 Address SDSF "ISFSLASH" "'"cmd"'  (WAIT)" 

But you should also have some error handler, like:
Code:
 say 'Sdsf' cmd 'rc' cc isfmsg 
 if datatype(isfmsg2.0)='NUM' then do n=1 to isfmsg2.0           
   say isfmsg2.n               
 end                           

Why do you use EXEC 'MFTD.REXX(STOPOPCC)' if STOPOCC is in your SYSEXEC lib?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1269
Location: Bamberg, Germany

PostPosted: Thu Mar 07, 2024 1:48 am
Reply with quote

When using ISFSLASH, the cmd to be issued is w/o the "/" prefix.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Thu Mar 07, 2024 2:29 am
Reply with quote

Indeed, thank you Joerg for pointing that out.
Sample:
cmd="S AESTSTC"
Back to top
View user's profile Send private message
Patrick Bacelar

New User


Joined: 05 Sep 2022
Posts: 15
Location: Brazil

PostPosted: Thu Mar 07, 2024 5:07 am
Reply with quote

Like this?


Code:
//STOPOPCC JOB (),'STOP OPCC',NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1),
// MSGCLASS=X                                                       
//*                                                                 
//STEP1   EXEC PGM=IKJEFT01,DYNAMNBR=20                             
//SYSEXEC DD DSN=MFTD.REXX,DISP=SHR                             
//SYSTSPRT DD SYSOUT=*                                             
//SYSTSIN  DD *                                                     
  %STOPOPCC                                                         
/*



Code:
/* REXX */                                           
TRACE R                                             
RCODE = ISFCALLS('ON')                               
"ALLOC F(ISFTRACE) DA('MFTD.SDSF.TRACE') SHR"     
CMD = "S OPCT"                                     
ADDRESS SDSF "ISFSLASH" CMD "(WAIT)"                 
"FREE F(ISFTRACE)"                                   
CALL ISFCALLS('OFF')                                 
/* ERROR HANDLING */                                 
SAY 'SDSF' CMD 'RC' RCODE ISFMSG                     
IF DATATYPE(ISFMSG2.0)='NUM' THEN DO N=1 TO ISFMSG2.0
  SAY ISFMSG2.N                                     
END                                                 
RETURN RCODE                                         
Back to top
View user's profile Send private message
Patrick Bacelar

New User


Joined: 05 Sep 2022
Posts: 15
Location: Brazil

PostPosted: Thu Mar 07, 2024 5:08 am
Reply with quote

RC(20) - According to the IBM website

Return codes for ISFSLASH
20 - A request failed due to an environmental error.

And I noticed this also:

"SDSF S OPCT RC 0 NOT AUTHORIZED FOR CMD"
SDSF S OPCT RC 0 NOT AUTHORIZED FOR CMD


%STOPOPCC
3 *-* RCODE = ISFCALLS('ON')
>>> "0"
4 *-* "ALLOC F(ISFTRACE) DA('IBMUSER.SDSF.TRACE') SHR"
>>> "ALLOC F(ISFTRACE) DA('IBMUSER.SDSF.TRACE') SHR"
5 *-* CMD = "S OPCT"
>>> "S OPCT"
6 *-* ADDRESS SDSF "ISFSLASH" CMD "(WAIT)"
>>> "ISFSLASH S OPCT (WAIT)"
+++ RC(20) +++
7 *-* "FREE F(ISFTRACE)"
>>> "FREE F(ISFTRACE)"
8 *-* CALL ISFCALLS('OFF')
>>> "OFF"
>>> "0"
9 *-* /* ERROR HANDLING */
10 *-* SAY 'SDSF' CMD 'RC' RCODE ISFMSG
>>> "SDSF S OPCT RC 0 NOT AUTHORIZED FOR CMD"
SDSF S OPCT RC 0 NOT AUTHORIZED FOR CMD
11 *-* IF DATATYPE(ISFMSG2.0)='NUM'
>>> "1"
*-* THEN
*-* DO N=1 TO ISFMSG2.0
>>> "1"
>>> "2"
12 *-* SAY ISFMSG2.N
>>> "ISF776I Processing started for action 1 of 2."
ISF776I Processing started for action 1 of 2.
13 *-* END
11 *-* DO N=1 TO ISFMSG2.0
12 *-* SAY ISFMSG2.N
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2548
Location: Silicon Valley

PostPosted: Thu Mar 07, 2024 7:54 am
Reply with quote

re: "NOT AUTHORIZED FOR CMD"

seems clear.

Perhaps try with a display command first. (might have less security requirements).

See www.ibm.com/docs/en/zos/3.1.0?topic=language-security-rexx
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2548
Location: Silicon Valley

PostPosted: Thu Mar 07, 2024 7:59 am
Reply with quote

One of the examples of ISFSLASH says
Quote:
Because the commands contain blanks, enclose them in single quotation marks.
Back to top
View user's profile Send private message
hankoerlemans

New User


Joined: 25 Jan 2018
Posts: 57
Location: Australia

PostPosted: Wed Mar 13, 2024 4:49 am
Reply with quote

Pedro is correct. Without the quotes the console sees an S command with no arguments and OPCT on a new "line".

And you might enjoy the copious quantities of messages you get when you add
Code:
//ISFRXDBG DD DUMMY

to the job.

It's quite possible you are missing a variety of authorizations in the SDSF and OPERCMDS RACF classes.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2548
Location: Silicon Valley

PostPosted: Thu Mar 14, 2024 12:01 am
Reply with quote

re: "//ISFRXDBG DD DUMMY"

Instead of DUMMY, shouldn't it be SYSOUT=* or a data set name so that the output is saved?
Back to top
View user's profile Send private message
hankoerlemans

New User


Joined: 25 Jan 2018
Posts: 57
Location: Australia

PostPosted: Thu Mar 14, 2024 3:18 am
Reply with quote

Nope dd dummy. Output goes to the terminal or SYSTSPRT in batch.
Back to top
View user's profile Send private message
Patrick Bacelar

New User


Joined: 05 Sep 2022
Posts: 15
Location: Brazil

PostPosted: Fri Mar 15, 2024 11:18 pm
Reply with quote

It seems to be really an authorization issue. I've been looking at other topics and people have problems executing commands in SDSF through jobs, even though they can perform these commands manually with their own user. I'll take a look at the RACF permissions and try again. I will update this topic with more information soon.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
Search our Forums:

Back to Top