29. Accessing files on UNIX mainframe

If in or out points to a name containing one or several '/' it is considered the complete name (inclusive path) of a file on the UNIX HFS file system on the mainframe.

 

As default any 'newline characters' ( '15'x) in the UNIX-file will break the file into records when the file triggers an action block in RXS - and the newline characters will be removed. And opposite: records are concatenated adding 15'x' between each record when writing from RXS to the UNIX file system. This entails that text files keep line breaks when transmitted between the two milieus.

The default behavior can be overruled:

func='binary' when reading from UNIX: indicates no handling of newline characters: all characters in the UNIX-file are transmitted. Accordingly the input data from UNIX into RXS will consist of just one record. (But notice that a record internally in RXS may consist up to 16 MB of data).

outfunc='binary' when writing to UNIX: all records written are concatenated in the UNIX-file without any interleaving newline characters.

(Notice UNIX files are strings (or streams) of bits, because no notion of record exists in UNIX.)

If out points to a new (a non existent) file, the new file will get acces-control-bits set to 'write and execute' for the user, write and execute for the group (provided that a group has been assigned to the directory in which the file resides) and 'read' for all other users.

 

Example 29.1

)action in='/home/r2d2/example.txt'

unit.1

)endaction

The example copies the indicated unix file to the mainframe file rxs.data. Being a text-file, each line triggers the action block separately, and the coding above results in a mainframe file where records maps the lines of the text file.

Example 29.2

)action in='/home/r2d2/example.bin'

)& func='binary'

do forever

if length(unit.1) > 80 then do

left(unit.1,80)

unit.1 = substr(unit.1,81)

end

else do

unit.1

end

end

)endaction

The example copies the indicated UNIX file to the mainframe file rxs.data. The action block is triggered just once, because func='binary' will treat the UNIX file as one single string of bytes. Writing this string on a mainframe file requires some programming to break the string into records, because a mainframe record only may contain 32.760 bytes. The programming in the action block solves this by creating 80 byte records when writing to the mainframe.

UNIX commands may be executed from inside RXS using the general order address='unix'. See section 33.