WinSCP and z/OS FTP Server
WinSCP is our company's (semi-)official FTP client of choice. As a member of the mainframe department, I connect to FTP servers running on IBM's z/OS most of the time.
All works well when using WinSCP in the interactive GUI-based mode. However, when trying to automate file transfers using WinSCP's batch interface, things turn out to be a little complicated.
While uploading files to the mainframe still works as expected, scripted downloads are restricted. It seems as if the main problem is that, before issuing the actual
RETR
command, WinSCP sends a LIST
command to the server. Apparently, it then attempts to find the name of the file to be downloaded within the received listing. This works as long as one does not specify a fully qualified z/OS dataset name (that is, a dataset name enclosed within single quotes) in the GET
batch statement. Trying to do so makes the operations fail with error messages of the type
Can't get attributes of file ''HLQ.DATASET.NAME''
On plain z/OS, there is basically no such concept as directories in terms of hierarchically organized folders which one can specify paths to. Rather, z/OS dataset names consist of multiple qualifiers all separated by periods. To account for this, on an FTP server running on z/OS, the
CWD
command does not actually change into the specified directory, but rather sets a certain dataset name prefix. In GET
or PUT
operations, in case they do not use a fully qualified dataset name, this dataset name prefix is prepended to the involved dataset names. For LIST
commands, only datasets with a name matching this prefix are returned. (As a side note and reflecting on this for a moment, one comes to the conclusion that, in the context of an FTP server, this behavior is actually not that far from and somewhat compatible to the concept of directories.)
Now, since after login the dataset name prefix is set to the name of the current user, the
LIST
command issued at the beginning of a GET
operation returns only those datasets which are under the HLQ of the user. In the interactive GUI-based mode, this is not a problem, since using the GUI the user is unlikely to specify a fully qualified dataset name, but will rather either download a dataset under his/her HLQ or CWD to the appropriate prefix before starting a download operation.
In both cases, WinSCP will find the requested dataset name in the listing returned by the
LIST
command.
In batch mode, however, one can specify a fully qualified dataset name as described above. Apparently, WinSCP issues a
LIST
rather than a LIST 'HLQ.DATASET.NAME'
command in this case. Consequently, the received listing will contain only those datasets matching the current dataset name prefix (i.e. the name of the current user) and not the requested one.
As a workaround, one can manually add an appropriate
CD
command and then use the dataset name without the specified prefix in the subsequent GET
operation. Apparently, this is also what WinSCP does automatically when specifying a fully qualified UNIX-style filename (i.e. one starting with /
).
Manually splitting the operations like this, however, makes things unnecessarily complicated.
Based on this, I would like to ask whether it is somehow possible to make WinSCP identify fully qualified z/OS dataset names by means of the leading
'
and then craft and issue the appropriate CD commands.
Thanks in advance!
Regards,
gustav_heinrich