tofile — read a stream of data from stdin and write to a z/OS POSIX file
The tofile command writes a stream of bytes to
filename using a stream of data read from stdin.
Codepage translation is performed and custom source line terminators are
respected depending on the options provided.
The tofile command runs in one of three environments:
locally (default on z/OS sytems)
remotely, from a client which was started by Co:Z launcher.
remotely, from a client that started a durable session to the server using the cozcontrol command.
remotely, from a client-initiated ssh connection:
filename is a path to the z/OS POSIX file to write. It may be either
an absolute path or relative path.
Specifies a remote invocation of tofile using a client-initiated ssh connection to the given z/OS user@host. If specified, this must be the first command option.
Specifies the use of local z/OS I/O, even if run via CoZLauncher. Applicable when the source and target are both z/OS. If specified, this must be the first command option.
filenamein append mode.
binary mode. Bytes are streamed as-is from stdin to the POSIX file.
begin writing data to
filenameimmediately (disable buffering). This is the default if used with a tunneled socket.
display help and exit.
source lines are separated by combination of linefeed and/or carriage return characters. The default is 'flexible' which allows for any of the other patterns above. These characters are taken from the source codepage.
source lines are followed with a hex character sequence. The sequence must be between 1 and 8 bytes long.
source lines do not have separators.
A comma-separated list of options to control logging and tracing.
Logging threshhold: eMergency, Alert, Critical, Error, Warning, Notice (default), Info, Debug, Trace, Fine.
Prefix log messages with a system timestamp
Include consumed cpu time in log messages
Messages are logged to
filenameon the server instead of stderr. If not fully qualified, the file is written to the user's home directory on the server.
Messages are logged to SYSLOG facility instead of stderr
Set the logging threshold for a specific component. Specify only at the request of product support personnel.
the file access mode (as an octal number) to apply to
do not replace
filenameif it exists.
make the path components to
filenameif they don't exist (ala mkdir -p).
Codepage conversion technique string. Used to override the default Unicode Services value of
LMREC. For more information, see IBM's Unicode Services User's Guide and Reference (SA22-7649).
the codepage name or numeric CCSID id of the data read from stdin. If not specified and invoked from a remote client, the default client codepage is used.
the codepage name or numeric CCSID id of the output
filename. If not specified, the default z/OS process codepage is used. Translation is disabled if source-codepage equals target-code- page.
-TSTANDARD | translate_table_dsname
Specifies the translate table to use for text mode transfers. This option overrides the
-s -t -qoptions if also given. If
STANDARD, the translate table TCPIP.STANDARD.TCPXLBIN is used. If a dataset name is supplied, it is expected to be in the format produced by the TSO CONVXLAT command. Only single byte translations are supported. Specifically, the dataset DCB must be LRECL=256,RECFM=F and contain two translation table records. The first record is an ASCII-to-EBCDIC mapping; the second record is an EBCDIC-to-ASCII mapping. Additional comment records (starting with * in the first column) are allowed.
the umask (as an octal number) to apply to
display the current version and exit.
allow for an empty input stream. If not specified, the default is to exit with an error and not open or write to the output filename if the input stream is empty.
Local z/OS Examples
tofile -t ISO8859-1 /home/user/myfile.iso8859 < myfile
Creates a copy of an HFS or zFS file locally, translating the default z/OS process codepage to ISO8859-1.
tofile -p /home/user/newdir/myfile < myfile
Copies an HFS or zFS file to a new location, creating any missing path components (e.g. newdir).
Remote Client SSH Connection Examples
tofile -ssh firstname.lastname@example.org /home/user/mydata < /tmp/data
Uploads a remote file over an SSH connection (Unix). Codepage translation is performed from the remote unix codepage to the current z/OS process codepage.
copy c:ata.txt con: | tofile -ssh email@example.com myfile.txt
Uploads a remote file over an SSH connection (Windows). The target filename is relative to the current user's $HOME directory. Codepage translation is performed from the remote Windows codepage to the current z/OS process codepage.
tofile -ssh firstname.lastname@example.org -b /home/user/data.bin < /tmp/data.bin
Uploads a remote file over an SSH connection as-is (no codepage translation is performed).
cat /tmp/myscript.sh | tofile -ssh -p 2222 email@example.com -m 0777 /home/user/myscript.sh
Uploads a remote file with additional ssh options. The target file will be given a file access mask of 0777 (rwxrwxrwx), but is subject to the user's existing umask.