SSH

Unattended File Transfers

Unattended file transfers of MVS data sets can be executed in JCL by BPXBATCH, BPXBATSL, or oshell. scpg3 uses the same syntax for interactive and unattended file transfers. sftpg3 has a batch mode for non-interactive file transfers.

[Note]Note

User interaction is not possible when using unattended file transfers.

Users must be set up to use a non-interactive authentication method for unattended use, such as public key without a passphrase.

Because user interaction is not possible, the server host key must be stored on disk on the client before unattended file transfers will succeed. More information and examples on storing remote server keys can be found in Server Authentication with Public Keys in File and Fetching Remote Server Keys.

The sample scripts shown in this section can also be found in the /opt/tectia/doc/zOS/SAMPLIB directory.

File Transfers Using the scpg3 z/OS Client

Example 1: Fetch a remote file into an MVS data set

This example (SCPGET from SAMPLIB) executes scpg3 and copies a remote file (file.bin) into a data set (//'USER.TEST.BINFILE'). If the data set does not exist, it is created with default values recfm VB and lrecl 1024.

The stdout and stderr message files are printed to SYSOUT. Required environment variables are supplied in SSHENV via STDENV DD. Modify the DD statement according to your requirements.

//SCPGET  EXEC PGM=BPXBATSL,REGION=0M
//STDPARM  DD  *
PGM /opt/tectia/bin/scpg3
  user@remote:file.bin
  //'USER.TEST.BINFILE'
//STDENV   DD  DSN=SSZ.SRVR6410.PARMLIB(SSHENV),DISP=SHR
//STDOUT   DD  SYSOUT=*
//STDERR   DD  SYSOUT=*
//STDIN    DD  DUMMY
//
Example 2: Put an MVS data set to a remote Windows file

In this example (SCPPUT1 from SAMPLIB), scpg3 is executed to copy a data set to a remote file (test.list), converting the code set from IBM-1047 to ISO8859-1 and records to CR-LF delimited lines.

The stdout and stderr message files are printed to SYSOUT. Required environment variables are supplied in SSHENV via STDENV DD. Modify the DD statement according to your requirements.

//SCPPUT1 EXEC PGM=BPXBATSL,REGION=0M,TIME=NOLIMIT
//STDPARM  DD  *
PGM /opt/tectia/bin/scpg3
  /ftadv:C=ISO8859-1,D=IBM-1047,I=DOS,J=MVS//__HLQ.TEST.LIST
  user@remote:test.list
//STDENV   DD  DSN=SSZ.SRVR6410.PARMLIB(SSHENV),DISP=SHR
//STDOUT   DD  SYSOUT=*
//STDERR   DD  SYSOUT=*
//STDIN    DD  DUMMY
//
Example 3: Put an MVS data set to a remote Unix file using translate table

In this example (SCPPUT from SAMPLIB), scpg3 is executed to copy a data set assigned to DD LIST to a remote file (test.list), performing code set translation via the 'TCPIP.STANDARD.TCPXLBIN' translate table.

The stdout and stderr message files are printed to SYSOUT. Required environment variables are supplied in SSHENV via STDENV DD. Modify the DD statement according to your requirements.

//SCPPUT  EXEC PGM=BPXBATSL,REGION=0M,TIME=NOLIMIT
//STDPARM  DD  *
PGM /opt/tectia/bin/scpg3
  /ftadv:E=STANDARD,A=___TCPIP.%T.TCPXLBIN,F=LINE///DD:LIST
  user@remote:test.list
//STDENV   DD  DSN=SSZ.SRVR6410.PARMLIB(SSHENV),DISP=SHR
//STDOUT   DD  SYSOUT=*
//STDERR   DD  SYSOUT=*
//STDIN    DD  DUMMY
//LIST     DD  DSN=&SYSUID..TEST.LIST,DISP=SHR
//
Example 4: Fetch a remote file into a pre-allocated MVS data set

In this example (SCPGET2 from SAMPLIB), a remote file (testfile) is copied into a pre-allocated data set, assigned to DD TEST.

The stdout and stderr message files are printed to SYSOUT. Required environment variables are supplied in SSHENV via STDENV DD. Modify the DD statement according to your requirements.

//SCPGET2 EXEC PGM=BPXBATSL,REGION=0M
//STDPARM  DD  *
PGM /opt/tectia/bin/scpg3
  user@remote:testfile
  //DD:TEST
//STDENV   DD  DSN=SSZ.SRVR6410.PARMLIB(SSHENV),DISP=SHR
//STDOUT   DD  SYSOUT=*
//STDERR   DD  SYSOUT=*
//STDIN    DD  DUMMY
//TEST     DD  DSN=&SYSUID..TEST,DISP=(NEW,CATLG),
//             VOL=SER=ZZSYS1,SPACE=(TRK,(2,2)),
//             DCB=(RECFM=VB,LRECL=1024,BLKSIZE=27998)
//
Example 5: Fetch a remote Unix ASCII file into a data set member

In this example (SCPGET3 from SAMPLIB), a remote Unix ASCII file (jcl.txt) is copied to mainframe into a PDS member using lrecl 80 and recfm FB, creating the PDS if it does not exist.

The stdout and stderr message files are printed to SYSOUT. Required environment variables are supplied in SSHENV via STDENV DD. Modify the DD statement according to your requirements.

//SCPGET3 EXEC PGM=BPXBATSL,REGION=0M
//STDPARM  DD  *
PGM /opt/tectia/bin/scpg3
  user@remote:jcl.txt
  /ftadv:C=ISO8859-1,D=IBM-1047,FI=80,DIRSZ=10///'USER.JCL(JCL1)'
//STDENV   DD  DSN=SSZ.SRVR6410.PARMLIB(SSHENV),DISP=SHR
//STDOUT   DD  SYSOUT=*
//STDERR   DD  SYSOUT=*
//STDIN    DD  DUMMY
//
Example 6: Fetch a remote Windows ASCII file into a data set member

In this example (SCPGET3W from SAMPLIB), a remote ASCII CRLF (Windows/DOS) file (jcl.txt) is copied to mainframe into a PDS member using lrecl 80 and recfm FB, creating the PDS if it does not exist.

The stdout and stderr message files are printed to SYSOUT. Required environment variables are supplied in SSHENV via STDENV DD. Modify the DD statement according to your requirements.

//SCPGT3W EXEC PGM=BPXBATSL,REGION=0M
//STDPARM  DD  *
PGM /opt/tectia/bin/scpg3
 user@remote:jcl.txt
 /ftadv:C=ISO8859-1,D=IBM-1047,I=DOS,J=MVS,FI=80,M=10///'USER.JCL(JCL1)'
//STDENV   DD  DSN=SSZ.SRVR6410.PARMLIB(SSHENV),DISP=SHR
//STDOUT   DD  SYSOUT=*
//STDERR   DD  SYSOUT=*
//STDIN    DD  DUMMY
//

File Transfers Using the sftpg3 z/OS Client

The sftpg3 file transfer application can be run in batch mode for non-interactive file transfers.

Example 1: Fetch a remote ASCII file into a data set member

In this example (SFTPBAT from SAMPLIB), sftpg3 is run in batch mode to copy a remote ASCII file (jcl.txt) into a PDS member using lrecl 80 and recfm FB. If the PDS does not exist, it will be created.

The stdout and stderr message files are printed to SYSOUT. Required environment variables are supplied in SSHENV via STDENV DD. Modify the DD statement according to your requirements.

//SFTP    EXEC PGM=BPXBATSL,REGION=0M
//STDPARM  DD  *
PGM /opt/tectia/bin/sftpg3 -B //DD:STDIN
  user@remote
//STDENV   DD  DSN=SSZ.SRVR6410.PARMLIB(SSHENV),DISP=SHR
//STDOUT   DD  SYSOUT=*
//STDERR   DD  SYSOUT=*
//STDIN    DD  *
sget jcl.txt \
  /ftadv:C=ISO8859-1,D=IBM-1047,FI=80,DIRSZ=10///'USER.JCL(JCL1)'
ls //'USER.JCL'
//
Example 2: Run sftpg3 using a batch command file

In this example (SFTP from SAMPLIB), sftpg3 is run in batch mode (with the -B option). Since it is not possible to enter a password, we use public-key authentication with no passphrase for the private key.

sftpg3 returns the highest error code as the return code from the run. BPXBATSL multiplies this by 256 and returns the product as the step's condition code.

Using the ls command may cause non-zero error codes, for example if a referenced data set is in use in another address space. Run listings in separate steps if it is important to get the proper condition codes from file transfers.

The stdout and stderr message files are printed combined to SYSOUT. Required environment variables are supplied in SSHENV via STDENV DD. Modify the DD statement according to your requirements.

//SFTP2   EXEC PGM=BPXBATSL,REGION=0M
//STDPARM  DD  *
PGM /opt/tectia/bin/sftpg3 -B //DD:STDIN
    user@remote
//STDENV   DD  DSN=SSZ.SRVR6410.PARMLIB(SSHENV),DISP=SHR
//STDOUT   DD  SYSOUT=*
//STDIN    DD  *
cd //'USER.TEST.REPORTS' 1
sget RPT1 /ftadv:RECFM=FB,LRECL=80///TEST.RPT1 2
ls -l //TEST.RPT1 3
/*
//
1

Change current working directory to //'USER.TEST.REPORTS'.

2

Fetch RPT1 to //TEST.RPT1.

3

List the contents of //TEST.RPT1 in long format.