Unlike standard FTP, SFTP has no site command for setting platform specific options. Co:Z SFTP file transfer options are set with a special ls command request of the form: ls /+<name=value>. They can be cleared with a request of the form: ls /+NO<name>.
Multiple options can be set by separating the key=value pairs with commas. An error is returned if one or more of the options was incorrectly specified, but the remaining options are set as requested.
The options directory /+/
is a pseudo directory on the server,
and it is possible to make it the working directory via the cd /+
command. From this directory, options may be set and listed without the /+
prefix.
The active options and their settings can be displayed by issuing the command ls /+.
Co:Z SFTP server file transfer options may be specified interactively or via configuration files. The active options are determined in the following priority order:
The
fixed:
section of/etc/ssh/cozsftp_server_config
(highest priority and non-modifiable)The first matching pattern (if any) from
$HOME/.ssh/cozsftp_server_config
The first matching pattern (if any) from
/etc/ssh/cozsftp_server_config
Previous interactive commands:
ls /+
(described below) in the same sessionThe environment variable
SFTP_ZOS_OPTIONS
The
default:
section of/etc/ssh/cozsftp_server_config
(lowest priority)
For a list of available options, see Appendix B, Co:Z SFTP options.
For a description of the cozsftp_server_config
file format, including
how to specify file name patterns, see Appendix C, Session config files.
All examples in the following sections can be run by most sftp clients, either from z/OS or from other platforms (Windows, linux, etc..). Note: There are some differences in the way clients interact with the server, so the output shown in the examples below (performed with the OpenSSH sftp client) may not match your output exactly.
sftp> ls /+mode=text /+mode=text sftp> ls /+ /+/clientcp=iso8859-1 /+/error.log /+/loglevel=I /+/mode=text /+/servercp=IBM-1047 /+/trim
sftp> ls /+showall /+showall=true sftp> cd /+ sftp> ls NOblksize NObufno clientcp=ISO8859-1 conddisp=catlg NOcopies NOdataclas NOdest NOdir NOdisp NOdsntype NOdsorg error.log estsize NOforms NOgdgnt NOhold NOjesjobname NOjesjobwait jeslrecl=80 jesowner=KIRK jesrecfm=f jesstatus=* NOlabel NOlike linerule=flexible loglevel=I lrecl=80 NOmaxvol NOmgmtclas mode=text NOmount NOnorecall NOoutdes overflow=wrap NOpad recfm=fb NOrelease replace NOreqexits NOreset NOretpd NOsequence servercp=IBM-1047 showall smf space=trk.3.2 NOspin NOstorclas NOsysout trim NOtrtch NOucount NOunit NOvol NOwriter sftp> ls noshowall,norecfm noshowall,norecfm sftp> ls clientcp=ISO8859-1 error.log loglevel=I lrecl=80 mode=text servercp=IBM-1047 space=trk.3.2 trim
Most implementations of the sftp specification, including OpenSSH, do not allow for transmission of detailed information from the server to the client in the event of an error. Adding dataset transfers to the mix only increases the need for better error reporting. To help alleviate this problem, the Co:Z sftp implementation provides a comprehensive logging facility that can be enabled and tuned by each user session.
Several of the above option listing examples show error.log
as one
of the options. This is actually an alias for the running session's log file, which is
usually written to the /tmp
directory (See the section called “Co:Z SFTP Server logging”
for more information on where this file is written). This alias can be used to easily retrieve
the log at anytime and examine it from the client.
This feature makes it possible to examine detailed error information from the client
without having to abandon the active sftp session. Users of graphical clients such as
winSCP and gFTP see an even greater advantage in that
the error.log file can be viewed simply by selecting the file and transferring it in
view
mode.
sftp> rm //user.coz.sampjcl Removing //user.coz.sampjcl Couldn't delete file: Failure sftp> get /+/error.log Fetching /+/error.log to error.log /+/error.log 100% 68 0.1KB/s 00:00 sftp> !cat error.log ZosUtil[E]: Dataset "USER.COZ.SAMPJCL" is a PDS. Use rmdir instead. sftp>
The Co:Z implementation of sftp accepts two prefix strings to identify
MVS datasets as absolute paths. The first (//
) is consistent
with IBM's common usage. A secondary form (/-/
) is also available,
as not all sftp clients will allow double slash characters to be sent.
The sftp cd command can be used to navigate around the
z/OS dataset space. Using the dataset prefix //
or
/-/
, the dataset space can be entered. Once there, traversal
up and down various dataset levels can be performed similarly to hierarchical
file systems.
Partitioned datasets are treated as directories as well. Once a PDS is made the current working directory, its members can be listed and retrieved like normal files.
Just as listing the entire catalog from the root is not allowed, it is not possible to make the catalog root the current working directory. As such, the command cd // will fail.
sftp> cd //user sftp> pwd Remote working directory: //USER sftp> cd coz.testjcl sftp> pwd Remote working directory: //USER.COZ.TESTJCL sftp> cd .. sftp> pwd Remote working directory: //USER.COZ
The get
and put
commands are used to
transfer datasets and PDS members. By default, the transfer mode is binary, and
when storing new datasets, the DCB defaults are determined by the system and are often RECFM=U.
Any options previously set via the ls /+option=value are in effect for any given transfer.
Note | |
---|---|
When using the z/OS datasets must be read or written sequentially, starting with the beginning of the datasets. SFTP clients that attempt to read or write non-sequentially will fail with an error: ZosDataset[E]: dataset read(or write) error: seek not allowed. |
$ sftp user@zos.com Connecting to zos.com... user@zos.com's password: sftp> ls /+mode=text /+mode=text sftp> get //USER.LOG.MISC Fetching //USER.LOG.MISC to USER.LOG.MISC
sftp> ls /+ /+/clientcp=ISO8859-1 /+/mode=text /+/servercp=IBM-1047 sftp> get //user.ssh.jcl(sshd) Fetching //user.ssh.jcl(sshd) to user.ssh.jcl(sshd)
sftp> get //user.coz.sampjcl(cozproc) cozproc.txt Fetching //user.coz.sampjcl(cozproc) to cozproc.txt sftp> cd //user.coz.sampjcl sftp> get runcoz Fetching //USER.COZ.SAMPJCL/runcoz to runcoz sftp> get * Fetching //USER.COZ.SAMPJCL/@@README to @@README Fetching //USER.COZ.SAMPJCL/BPXBATCH to BPXBATCH Fetching //USER.COZ.SAMPJCL/BPXBATSL to BPXBATSL Fetching //USER.COZ.SAMPJCL/COZCFGD to COZCFGD Fetching //USER.COZ.SAMPJCL/COZPROC to COZPROC Fetching //USER.COZ.SAMPJCL/DTLSPAWN to DTLSPAWN Fetching //USER.COZ.SAMPJCL/GPGDSN to GPGDSN Fetching //USER.COZ.SAMPJCL/GREPDSN to GREPDSN Fetching //USER.COZ.SAMPJCL/GREPSED to GREPSED Fetching //USER.COZ.SAMPJCL/OFFLDSMF to OFFLDSMF Fetching //USER.COZ.SAMPJCL/RUNCOZ to RUNCOZ Fetching //USER.COZ.SAMPJCL/RUNCOZ2 to RUNCOZ2 Fetching //USER.COZ.SAMPJCL/RUNCOZ3 to RUNCOZ3 Fetching //USER.COZ.SAMPJCL/RUNSPAWN to RUNSPAWN Fetching //USER.COZ.SAMPJCL/RUNSPWN2 to RUNSPWN2 Fetching //USER.COZ.SAMPJCL/TDIRK to TDIRK Fetching //USER.COZ.SAMPJCL/WGET2DSN to WGET2DSN
... sftp> ls /+mode=text,lrecl=80,recfm=fb /+mode=text,lrecl=80,recfm=fb sftp> put afile.txt //USER.AFILE.TXT Uploading afile.txt to //USER.AFILE.TXT
MVS datasets can be listed using the sftp ls command. Partitioned datasets are treated as directories with their members as entries.
In order to support existing sftp clients, several considerations have to be made when listing datasets:
The ls lists multiple dataset levels (by default), and therefore can return a large amount of information. As such, listings that would involve searching the entire catalog, such as ls // or ls //A* are not allowed. Furthermore, because of the way sftp clients interact with the server, the following style of command is not supported: ls //USER.LVL1*. However, the same effect can be produced by either using directory notation for searching the catalog (ls //USER/LVL1*) or changing to the desired level and issuing a relative listing command:
cd //USER ls LVL1*
Note Wildcard support for listing datasets is dependent on client support, since it is up to the client to read the "directory" and filter matches. Where possible, dataset names are treated as case insensitive. A get or put can specify the name in either lower or upper case and it will be found. However, any globbed (wildcard) ls command requires upper case characters. Individual datasets can be listed in either upper or lower case. To be safe, it is a good idea to use upper case on all list requests.
As mentioned above, partitioned datasets (PDS) are treated as directories. the long list form ls -l can be used to list member statistics, if statistics exist.
The ls accepts dataset names prefixed either by
//
or/-/
. The second form should be used for the few sftp clients that do not allow a double slash to sent to the server.
sftp> cd //USER sftp> ls -al Volume Referred Ext Tracks Used Recfm Lrecl BlkSz Dsorg Dsname WORK84 2008/09/05 1 1 1 FB 80 27920 PS USER.AFILE.TXT WORK81 2008/09/08 1 30 ? U 0 6144 PO-E USER.COZ.LOADLIB WORK81 2008/09/11 1 15 4 FB 80 27920 PO USER.COZ.SAMPJCL WORK84 2008/09/11 1 1 1 U 0 6144 PS USER.COZ.TEST.SEQ WORK81 2008/09/09 1 15 3 FB 80 27920 PO USER.COZ.TESTJCL sftp> cd //USER sftp> ls CO* COZ.LOADLIB/ COZ.SAMPJCL/ COZ.TEST.SEQ COZ.TESTJCL/ sftp> ls //USER/CO* //USER/COZ.LOADLIB/ //USER/COZ.SAMPJCL/ //USER/COZ.TEST.SEQ //USER/COZ.TESTJCL/ sftp> ls //USER.CO* Couldn't get handle: Failure Can't ls: "//USER.CO*" not found sftp> ls // Couldn't stat remote file: No such file or directory Can't ls: "//" not found sftp> cd //user sftp> ls co* Can't ls: "//USER/co*" not found sftp>
... sftp> cd //user.coz.sampjcl sftp> ls -al Name Size Created Changed ID @@README BPXBATCH 13 2008/04/04 2008/04/04 17:18:09 USER BPXBATSL 16 2008/04/03 2008/04/03 10:36:52 USER COZCFGD 65 2008/03/27 2008/05/12 14:28:54 USER COZPROC 30 2008/03/27 2008/03/27 11:54:48 USER DTLSPAWN 40 2008/05/05 2008/05/05 09:31:08 USER GPGDSN 15 2008/05/05 2008/05/05 10:40:05 USER GREPDSN GREPSED 12 2008/05/05 2008/05/05 09:30:51 USER OFFLDSMF RUNCOZ 20 2008/03/27 2008/05/12 14:08:02 USER RUNCOZ2 15 2008/05/05 2008/05/05 10:02:51 USER RUNCOZ3 8 2008/05/05 2008/05/06 08:50:37 USER RUNSPAWN 54 2008/05/12 2008/05/12 14:25:37 USER RUNSPWN2 20 2008/05/12 2008/05/12 13:19:05 USER TDIRK 18 2008/04/03 2008/04/03 10:19:20 USER WGET2DSN
This section describes how to use the Co:Z implementation of sftp with POSIX files (HFS, zFS) on z/OS. Standard sftp implementations (including z/OS OpenSSH) support only binary mode file transfers. The Co:Z implementation provides binary transfer mode by default, but also supports text mode transfers. Text mode transfers are controlled via the following options:
mode
: when set totext
causes file transfers to be text based.clientcp
andservercp
: When text mode is active, these settings determine the codepage translation that will take place. The default client code page isISO8859-1
. The default server code page is the current z/OS locale.linerule
: When text mode is active, this setting determines how line separators are converted between the client and server.
The get
and put
commands are used to
transfer POSIX files (either on HFS or zFS filesystems).
The options (listed above) that have been previously set via the ls /+option=value are in effect for any given transfer. All other options (used for dataset support) are ignored for POSIX file transfers.
sftp> ls /+mode=text,clientcp=UTF-8 /+mode=text,clientcp=UTF-8 sftp> ls /+ /+/clientcp=UTF-8 /+/mode=text /+/servercp=IBM-1047 sftp> get .ssh/sftp-server.rc Fetching /u/user/.ssh/sftp-server.rc to sftp-server.rc /u/user/.ssh/sftp-server.rc 100% 234 0.2KB/s 00:00 sftp>
This section describes how to use Co:Z SFTP to submit jobs, query job status and access spool files on z/OS. Future releases of Co:Z SFTP will also support enhanced job cancel and purge facilities.
Note: Co:Z JES spool access supports both JES2 and JES3, but is currently limited to the primary JES subsystem.
To query the status of z/OS jobs, you simply list the "//-JES"
pseudo-directory:
sftp> cd //-JES sftp> ls JOB00434 JOB00561 TSU00560 TSU00562 sftp> ls -al JOBNAME JOBID OWNER STATUS CLASS KIRKL JOB00434 KIRK OUTPUT A RC=0000 TOMCAT JOB00561 KIRK ACTIVE A KIRK TSU00560 KIRK OUTPUT TSU RC=0000 KIRK TSU00562 KIRK ACTIVE TSU sftp> ls /+jesjobname=kirk /+jesjobname=kirk sftp> ls -al JOBNAME JOBID OWNER STATUS CLASS KIRKL JOB00434 KIRK OUTPUT A RC=0000 KIRK TSU00560 KIRK OUTPUT TSU RC=0000 KIRK TSU00562 KIRK ACTIVE TSU sftp> ls /+jesjobname=kirk. /+jesjobname=kirk. sftp> ls -al JOBNAME JOBID OWNER STATUS CLASS KIRK TSU00560 KIRK OUTPUT TSU RC=0000 KIRK TSU00562 KIRK ACTIVE TSU sftp> ls /+nojesjobname /+nojesjobname sftp> ls /+jesowner=goetze /+jesowner=goetze sftp> ls -al JOBNAME JOBID OWNER STATUS CLASS GOETZEB JOB00601 GOETZE OUTPUT A RC=0000 GOETZE TSU00505 GOETZE OUTPUT TSU RC=0000 GOETZE TSU00515 GOETZE ACTIVE TSU sftp> ls /+jesstatus=active /+jesowner=goetze sftp> ls -al JOBNAME JOBID OWNER STATUS CLASS GOETZE TSU00515 GOETZE ACTIVE TSU
Co:Z SFTP uses the unauthorized "Extended Status" subsystem interface to obtain job status. This facility is only available if you are running z/OS 1.9 or later. A SAF(RACF) SECLABEL dominance check may be used by the IBM extended status subsystem interface to control access to this facility; refer to RACF or your security product documentation for more information.
Job spool files may be transferred using normal SFTP "get" commands from your SFTP client.
sftp> cd //-JES sftp> ls -al JOBNAME JOBID OWNER STATUS CLASS KIRKL JOB00434 KIRK OUTPUT A RC=0000 TOMCAT JOB00561 KIRK ACTIVE A KIRK TSU00560 KIRK OUTPUT TSU RC=0000 KIRK TSU00562 KIRK ACTIVE TSU sftp> cd JOB00434 sftp> ls 102 2 3 4 sftp> ls -al DSID STEPNAME PROCSTEP DDNAME C OWNER RECFM LRECL BYTES 102 LOGDEF SYSPRINT A KIRK FBA 133 5195 2 JES2 JESMSGLG A KIRK FA 133 911 3 JES2 JESJCL A KIRK V 136 271 4 JES2 JESYSMSG A KIRK VA 137 839 sftp> ls -alf DSID STEPNAME PROCSTEP DDNAME C OWNER RECFM LRECL BYTES 2 JES2 JESMSGLG A KIRK FA 133 911 3 JES2 JESJCL A KIRK V 136 271 4 JES2 JESYSMSG A KIRK VA 137 839 102 LOGDEF SYSPRINT A KIRK FBA 133 5195 sftp> ls /+mode=text /+mode=text sftp> get 102 logdef.text Fetching //-JES.JOB00434/102 to logdef.text //-JES.JOB00434/102 sftp> sftp> get * Fetching //-JES.JOB00434/102 to 102 //-JES.JOB00434/102 Fetching //-JES.JOB00434/2 to 2 //-JES.JOB00434/2 Fetching //-JES.JOB00434/3 to 3 //-JES.JOB00434/3 Fetching //-JES.JOB00434/4 to 4 //-JES.JOB00434/4 sftp> sftp> get all concat.txt Fetching //-JES.JOB00434/all to concat.txt sftp> get jesysmsg Fetching //-JES.JOB00434/jesysmsg to jesysmsg sftp> get logdef.sysprint Fetching //-JES.JOB00434/logdef.sysprint to logdef.sysprint
Using the jesincsysin
option (available on z/OS 1.10 or later):
sftp> ls /+jesincsysin /+jesincsysin sftp> ls -alf DSID STEPNAME PROCSTEP DDNAME C OWNER RECFM LRECL BYTES 1 JESJCLIN A KIRK F 80 316 2 JES2 JESMSGLG A KIRK FA 133 911 3 JES2 JESJCL A KIRK V 136 271 4 JES2 JESYSMSG A KIRK VA 137 839 101 LOGDEF SYSIN A KIRK F 80 177 102 LOGDEF SYSPRINT A KIRK FBA 133 5195 sftp> get all concat.txt Fetching //-JES.JOB00434/all to concat.txt sftp>sftp> get jesjclin Fetching //-JES.JOB00434/JESJCLIN to jesjclin
Co:Z SFTP uses the unauthorized interface to the JES "Spool Browse" facility, which is only available if you are running z/OS 1.9 or later. As with IBM FTP, the SAF(RACF) JESSPOOL resource class is used to control access to spool files throuh the Spool Browse facility.
Jobs may be submitted to the JES internal reading using SFTP "put" commands from your SFTP client into a special pseudo-directory named "//-JES.INTRDR".
sftp> ls /+mode=text /+mode=text sftp> get //kirk.test.jcl(sleep3) jcl.txt Fetching //kirk.test.jcl(sleep3) to /tmp/jcl.txt sftp> !cat jcl.txt //SLEEP3 JOB (),'Kirk Wolf',MSGCLASS=H //UNIX EXEC PGM=COZBATCH //STEPLIB DD DISP=SHR,DSN=KIRK.COZ.LOADLIB //STDIN DD * for i in 1 2 3 do echo "Sleeping..." sleep 1 done // sftp> cd //-jes.intrdr sftp> put jcl.txt myjob Uploading jcl.txt to //-JES.INTRDR/myjob sftp> ls -al ALIAS JOBNAME JOBID OWNER STATUS CLASS COMPL MYJOB SLEEP3 JOB01941 KIRK ACTIVE A sftp> ls -al ALIAS JOBNAME JOBID OWNER STATUS CLASS COMPL MYJOB SLEEP3 JOB01941 KIRK OUTPUT A RC=0000 sftp> cd myjob sftp> ls -alf DSID STEPNAME PROCSTEP DDNAME C OWNER RECFM LRECL BYTES 2 JES2 JESMSGLG H KIRK FA 133 1316 3 JES2 JESJCL H KIRK V 136 373 4 JES2 JESYSMSG H KIRK VA 137 824 102 UNIX SYSOUT H KIRK FBA 121 308 sftp> get 2 2.txt Fetching //-JES.INTRDR.MYJOB/2 to /tmp/2.txt sftp> get all jobout.txt Fetching //-JES.INTRDR.MYJOB/all to /tmp/jobout.txt sftp> cd .. sftp> put jcl.txt myjob2 sftp> ls -al ALIAS JOBNAME JOBID OWNER STATUS CLASS COMPL MYJOB SLEEP3 JOB01941 KIRK OUTPUT A RC=0000 MYJOB2 SLEEP3 JOB01943 KIRK ACTIVE A sftp> ls /+jesjobwait /+jesjobwait sftp> cd myjob2 sftp> get all jobout2.txt Fetching //-JES.INTRDR.MYJOB2/all to /tmp/jobout2.txt sftp> ls /+jesjobwait=10.1 sftp> ls /+nojesjobwait
Here's a similar example, using the Windows sftp client PuTTY psftp to non-interactively download some JCL, submit it, wait for it to run, and then download the output:
C:\Users\kirk> type psftp-input.txt ls /+mode=text,jesjobwait get //kirk.test.jcl(sleep3) jcl.txt cd //-jes.intrdr put jcl.txt myjob dir cd myjob dir get all sleep3.log C:\Users\kirk> psftp -b psftp-input.txt kirk@zos.myco.com Using username "kirk". Remote working directory is /u/kirk Listing directory /+mode=text,jesjobwait jesjobwait mode=text remote://KIRK.COZ.TESTJCL(SLEEP3) => local:jcl.txt Remote directory is now //-JES.INTRDR local:jcl.txt => remote://-JES.INTRDR.MYJOB Listing directory //-JES.INTRDR ALIAS JOBNAME JOBID OWNER STATUS CLASS COMPL MYJOB SLEEP3 JOB03165 KIRK INPUT A Remote directory is now //-JES.INTRDR.MYJOB Listing directory //-JES.INTRDR.MYJOB DSID STEPNAME PROCSTEP DDNAME C OWNER RECFM LRECL BYTES 102 UNIX SYSOUT H KIRK FBA 121 311 2 JES2 JESMSGLG H KIRK FA 133 1064 3 JES2 JESJCL H KIRK V 136 247 4 JES2 JESYSMSG H KIRK VA 137 1044 remote://-JES.INTRDR.MYJOB.ALL => local:sleep3.joblog
The following table describes options that affect JES submit, status, and spool file transfer.