Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Displaying OMVS information through REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
rahul1586

New User


Joined: 04 Nov 2008
Posts: 28
Location: Mumbai

PostPosted: Tue Sep 27, 2011 12:09 pm    Post subject: Displaying OMVS information through REXX
Reply with quote

Hello,

I am using the following code which I found in an IBM link to display the current working directory and list the contents of a directory that I specify as a parameter or after a prompt.

Code:

/*   rexx  */
parse arg dir
address syscall 'getcwd cwd'
say 'current directory is' cwd
if dir=' ' then
   do
   say 'enter directory name to list'
   parse pull dir
   end
'ls -l' dir
return


I am getting the follwing output.
Code:

current directory is /       
enter directory name to list
/stcell                         
IKJ56500I COMMAND LS NOT FOUND 
    11 *-* 'ls -l' dir         
       +++ RC(-3) +++           


The 'ls -l' command is not working.
Can anybody tell me what is wrong with this?

Thanks
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Sep 27, 2011 12:29 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

You are executing the -ls command in whatever environment is your default. You need to kick it down to the Unix operating system in the same way as you did the getcwd, at a guess.
Back to top
View user's profile Send private message
rahul1586

New User


Joined: 04 Nov 2008
Posts: 28
Location: Mumbai

PostPosted: Wed Oct 05, 2011 12:15 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

Hello

I am able to display the contents of OMVS file using below code
Code:

FN = abc.xyz.123     
CALL SYSCALLS 'ON'                   
ADDRESS SYSCALL                       
 'readfile '||FN||' list. '           
     DO I = 1 TO LIST.0 
          say list.i
end   
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Oct 05, 2011 12:22 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

Are you saying you still have a problem? Or are you saying "I can do this, but still can't get the -ls to work"?
Back to top
View user's profile Send private message
rahul1586

New User


Joined: 04 Nov 2008
Posts: 28
Location: Mumbai

PostPosted: Wed Oct 05, 2011 12:28 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

Quote:

Are you saying you still have a problem? Or are you saying "I can do this, but still can't get the -ls to work"?


Thanks Bill.

What I meant was I am able to read the contents of a particular file using the readfile command.
But I am unable to use 'ls -l'

its giving output as command not found.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Oct 05, 2011 1:20 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

Did you try

Code:
address syscall 'ls -l'


Or simply try after your "address syscall" with no parameters, like in your second snippet?

If you have a way to get one unix command working, that will work for another. With your existing ls, you are not sending it off to another environment (unix) but just trying it whereever you happen to be at the time.
Back to top
View user's profile Send private message
rahul1586

New User


Joined: 04 Nov 2008
Posts: 28
Location: Mumbai

PostPosted: Wed Oct 05, 2011 1:55 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

Bill,

I tried this code..
Code:

trace i                                   
PARSE ARG DIR                             
CALL SYSCALLS 'ON'                         
ADDRESS SYSCALL 'getcwd cwd'               
SAY 'CURRENT DIRECTORY IS' CWD             
IF DIR=' ' THEN                           
   DO                                     
   SAY 'ENTER DIRECTORY NAME TO LIST'     
   PARSE PULL DIR                         
   END                                     
ADDRESS SYSCALL 'ls -l'                   
   RETURN                                 


output:
Code:

3 *-* PARSE ARG DIR     
  >>>   ""               
4 *-* CALL SYSCALLS 'ON'
        >L>   "ON"                                   
        >>>   "0"                                   
      5 *-* ADDRESS SYSCALL 'getcwd cwd'             
        >L>   "getcwd cwd"                           
      6 *-* SAY 'CURRENT DIRECTORY IS' CWD           
        >L>   "CURRENT DIRECTORY IS"                 
        >V>   "/"                                   
        >O>   "CURRENT DIRECTORY IS /"               
 CURRENT DIRECTORY IS /                             
      7 *-* IF DIR=' '                               
        >V>   ""                                     
        >L>   " "                                   
        >O>   "1"                                   
        *-*  THEN                                   
      8 *-*  DO                                     
      9 *-*   SAY 'ENTER DIRECTORY NAME TO LIST'     
        >L>     "ENTER DIRECTORY NAME TO LIST"       
 ENTER DIRECTORY NAME TO LIST                       
     10 *-*   PARSE PULL DIR                         
/stcell                                             
        >>>     "/stcell"                           
     11 *-*  END                                     
     12 *-* ADDRESS SYSCALL 'ls -l'                 
    >L>   "ls -l"               
    +++ RC(-20) +++             
 13 *-* RETURN                   
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Oct 05, 2011 2:48 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

And don't you feel that that is an improvement?

You don't get a mainframe message any longer, so a step forward.

Your getcwd is showing a "root" directory. You don't do anything to change the directory to the one requested/passed as an argument. So your -ls is going to the root. My guess would be you don't have permission for -ls on the root.

Why don't you now include the directory on your -ls (like you had before), or change directory to the one supplied and do the -ls (perhaps better, then you don't have to include the directory on every command).

Have a look back in the rexx forum, by the way, for a post from enrico showing a "wrapper" technique. It is a really good way to manage things. If you do all your "address" stuff to seperate pieces of correct code you'll find things go more smoothly.
Back to top
View user's profile Send private message
rahul1586

New User


Joined: 04 Nov 2008
Posts: 28
Location: Mumbai

PostPosted: Wed Oct 05, 2011 8:36 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

Hello,

Quote:
Why don't you now include the directory on your -ls (like you had before), or change directory to the one supplied and do the -ls (perhaps better, then you don't have to include the directory on every command).


I tried that too. Still getting RC(-20)

Quote:
, for a post from enrico showing a "wrapper" technique.


Will read abt this now and see if it can help here.

Thanks
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Oct 05, 2011 9:20 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

enrico's wrappers are a good method to ensure that you "external" (to rexx) commands always go to where they should, that you don't have 99 working correctly and another one popping off somewhere else.

Your original problem was the the "-ls" was not getting to the target system, because you didn't tell it to.

Now you are getting the "20". The command is arriving, but the "20" is telling you something.

If you can get the current-working-directory and can't list the contents of the directory, I think you have a "permissions" problem. That the logon which you are using does not have authority to do anything to the directory. If you know of a sub-directory that exists, can you change-directory to it? Are you able to make-directory?

Are you able to login with that id manually and try the ls? Are you able to find out what a 20 rc might mean from the unix underneath?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Oct 05, 2011 9:42 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

when somebody does not read the manuals they usually get a -20 return code icon_biggrin.gif

in general a -20 return code from an Address SOMEENVIR "somecommand"
tells that the somecommand is not supported by the SOMENVIR environment

the manual
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/BPXZB680/CCONTENTS?DT=20080602214011

will tell what <commands> are supported by the SYSCALL environment

and certainly LS is not one of them
in this case the proper syntax would be tested and working
Code:
Address SYSCALL "readdir /  dir."                                       
do i = 1 to dir.0                                                       
   say dir.i                                                         
end                                                                     


odd that
Code:
Address SYSCALL "getcwd cwd"                                       
say cwd                                                                                                                                                                         

returns CWD verbatim ( an uninitialized variable )

in a FULL Unix environment the environment to be addressed for LS

would be certainly BASH or the equivalent for the shell being used

Code:
Address BASH "ls / | rxqueue"
if RC \= 0 then exit

do while ( queued() > 0 )
   parse pull z
   say z
end
Back to top
View user's profile Send private message
rahul1586

New User


Joined: 04 Nov 2008
Posts: 28
Location: Mumbai

PostPosted: Wed Oct 05, 2011 9:48 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

Thanks a lot enrico.

I will go thru the link and use the commands which are supported in SYSCALLS environment.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Oct 05, 2011 10:04 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

quite odd that You found the ls stuff on an IBM link
the IBM docs say something different


Quote:
This example prints the contents of the root directory to standard output:


/* rexx */
call syscalls 'ON'
address syscall
'readdir / root.'
do i=1 to root.0
say root.i
end


http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/BPXZB680/4.1?DT=20080602214011
Back to top
View user's profile Send private message
rahul1586

New User


Joined: 04 Nov 2008
Posts: 28
Location: Mumbai

PostPosted: Wed Oct 05, 2011 10:28 pm    Post subject: Reply to: Displaying OMVS information through REXX
Reply with quote

I found the code in

z/OS V1R12.0 Using REXX and z/OS UNIX System Services
SA22-7806-13

In the examples of using SYSCALLS command there is the example which I used Display the working directory and list a specified directory

My site has zOS v1r11 and this link is for zOS v1r12.

Could that be the reason that the command is not working at my site?

Anyway the same link has the SYSCALLS command descriptions which I can use in my code icon_biggrin.gif

Thanks
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Need to code a Rexx PGM sundaram.naveen CLIST & REXX 18 Thu Oct 06, 2016 6:45 pm
No new posts Obtaining file information pahiker COBOL Programming 25 Tue Sep 27, 2016 7:25 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us