Accessing MVS data sets within sftp
OpenSSH's sftp does not have built-in support for MVS™ data sets. However, there are alternate (indirect) ways to access MVS data sets within sftp.
Solution 1
From within sftp, use a shell escape to copy between MVS and the z/OS® UNIX file system. Do this by preceding any shell command by a '!'.
For example:
!cp "//'CTWARE.C(HELLO)'" hello.c
The
'HELLO' member is copied to a local file hello.c,
which could then be transferred from sftp.
This would be executed while you are within an sftp shell. Note: The hello.c file
will remain in the z/OS UNIX file
system until it is manually removed.
You can use this solution from within an sftp batch
file as well, to automate certain tasks or help in removal of the
file:
> cat batchfile
lcd sftptest
cd Test
!cp "//'CTWARE.C(HELLO)'" hello.c
put hello.c
!rm hello.c
> sftp -b batchfile user@remotehost
This example would
change directories (both local and remote), copy an MVS dataset to
the z/OS UNIX file system (on the local
machine), transfer the file (to the remote system), and then remove
the (local) z/OS UNIX file system copy. This would
save you some work, and you would not have to manually remove 'temporary'
files. Tip: Because the sftp exit value is not affected by shell command escapes, Solution 2 is preferred if verification of a successful copy is required.
Solution 2
Copy the data from an MVS dataset to the z/OS UNIX file system prior to using sftp.
For example:
cp "//'CTWARE.C(HELLO)'" hello.c
The
'HELLO' member is copied to a local file hello.c,
which could then be transferred from sftp.
This would be executed from a standard z/OS UNIX shellNote: The hello.c file remains in the z/OS UNIX file
system until it is manually removed.