33. Address: Special interpretation of output

33a. Changing address

The RXS general order address='xxx' will change the basic behaviour of RXS: strings are no longer sent to stdout, but are sent to the environment xxx stated by address.

address is local for an action block. 

Default addressing in RXS is therefore address='stdout' meaning that strings are sent to the environment stdout.

The environment stdout is the normal handler of (sequential) output from RXS. Stdout normally writes strings created by RXS to the dataset RXS.DATA, but the behaviour of stdout can be modified - see section 4 and section 7.

Any environment that can be addressed in REXX can be addressed in RXS. Below are some often used environments for RXS:

33b. Addressing ISPEXEC

address='ispexec' indicates that all strings from this action block are handled over to ispexec to be interpreted as orders for ISPF.

If an addressed command gives a return code, RC > 11, then RXS is terminated in error. If the addressing in this situation is ispexec or isredit then the error message in the addressed system will be displayed.

Example 33.4:

)action address='ispexec'

"display panel(mypanel) cursor(myfld)"

)endaction

The example uses ISPF for displaying a window. In case of errors in the ISPF display, an ISPF error message will be shown.

33c. Addressing UNIX

address='unix' will direct strings in the action block to UNIX for execution.

Output from such commands is written to stdout for the action block.

Errors from such commands is written on the screen. Errors will halt the RXS program with RC = 20

Example 33.5:

)action address='unix'

"cd /home/r2d2/mess"

"cksum myfile.rxs>cksumfile.txt"

)endaction

The example changes the actual directory in UNIX, and executes the UNIX command cksum against a file on the actual directory.

 

Example 33.6:

)action address='unix'

)&      out='q1'

"ls /home/r2d2/"

)endaction

)action in='q1'

  word.1

)endaction

The example list all files in the directory /home/r2d2/. The listing of the directory will be written on mvs dataset RXS.DATA

33d. Addressing Java via UNIX

Example 33.7:

Zipping a unix file om manframe:

)action address='unix'           

  "cd /main_dir/our_dir/     "

  "jar cfv hovsa.zip r2d2.txt "

)endaction    

The example zips the file /main_dir/our_dir/r2d2.txt to the zip-archive hovsa.zip which is created on the same directory. More than one file may be zipped:  

  "jar cfv hovsa.zip yrsa.txt r2d2.txt "

 

Example 33.8:

UNZIP a zip.archive to a unix file om manframe:

)action address='unix'           

  "cd /main_dir/our_dir/     "

  "jar xfv hovsa.zip "

)endaction    

The original file(s) are extracted from the zip-archive hovsa.zip on the directory /main_dir/our_dir. The file(s) are placed on the same directory

33e. Addressing TSO

address='tso' will direct strings in the action block over to tso for execution.

Output from such commands is is written to stdout for the action block.

If a tso command sets a return code 8 or more, the RXS program is halted.

33f. Communicating to a remote system by FTP

Getting an unix-file from remote:

Example 33.9:

)action address='tso'

queue "R2D2"

queue "is_secrt"

queue "binary"

queue "lcd /home/R2D2"

queue "cd /home/Stranger"

queue "get lyrics.txt (replace "

queue "quit"

"FTP EXMACHINE.REMOTE.COM"

)endaction

The example performs an FTP transport of unit-file lyrics.txt from unix-directory home/stranger on EXMACHINE.REMOTE.COM over to /home/R2D2 on the local mainframe. User R2D2 with password is_secrt is authenticating the transport.

Note the use of instruction 'queue' to set op a list of answers to the questions we know that the FTP tso command is going to ask.

 

Putting a member from a MVS partitioned dataset or library to remote:

Example 33.10:

)action  

queue "R2D2"

queue "is_secrt"

queue "lcd 'ourqual.ourlib.cntl'

queue "cd 'remqual.theirlib.cntl'"

queue "put killroy "

queue "quit"

)action address='tso'

)&      out='ftp_mess'

"FTP EXMACHINE.REMOTE.COM"

)endaction

)endaction

)action in='ftp_mess'

)&   errorc=1

select

when word.1 = 'EZA2644I' then do

errorc = 2

say substr(unit.1,9)

end

when word.1 = 'EZA2836I' then do

say substr(unit.1,9)

errorc = 2

end

when word.1 = 'EZA1684W' then do

say substr(unit.1,9)

errorc = 2

end

when word.1 = 'EZA1617I' then do

say substr(unit.1,9)

errorc = ''

end

otherwise nop

end

)endaction

)action

select

when errorc = 2 then do

say 'FTP fails'

exit 16

end

when errorc = 1 then do

say 'FTP fails. Probably wrong password on extern, or',

'wrong filename on extern'

exit 16

end

otherwise say 'FTP was a success'

end

)endaction

 

The example performs an FTP transport of member 'killroy' from dataset 'remqual.theirlib.cntl'  on external mainframe EXMCHINE.REMOTE.COM . The data will be recived on 'ourqual.ourlib.cntl(killroy)'. User R2D2 with password is_secrt is authenticating the transport.

Note the use of instruction 'queue' to set op a list of answers to the questions we know that the FTP tso command is going to ask.

The RXS program performs an analysis on the output from FTP to verify whether the transfer succeeded.