Your browser does not support HTML5 local storage or you have disabled it. Some functionality on this site, including saving your privacy settings and offering you special discounts, uses local storage and may not work with local storage disabled. We recommend allowing the use of local storage in your browser. In some browsers, it is the same setting used for disabling cookies.

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: A Unix file transferred to a z/OS sequential data set

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

Required environment variables are defined by using the STDENV DD card. The scpg3 command is run by BPXBATCH. Separate step for printing the stdout and stderr message files is required in order to get correct return code from the file transfer operation.

//SCPGET EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=0M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCPGET.out',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCPGET.err',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDENV   DD  DSN=&SYSUID..SSZ.SRVR63.PARMLIB(SSHENV),
//             DISP=SHR
//SYSTSIN  DD  *
  BPXBATCH PGM /opt/tectia/bin/scpg3 +
        user1@remote_host:textfile.txt +
        //'USERID.TEST.TEXTFILE'
/*
//STDPR   EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=0M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCPGET.out',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCPGET.err',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDOUTPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//STDERRPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//SYSTSIN  DD  *
  OCOPY INDD(STDOUT) OUTDD(STDOUTPR) TEXT
  OCOPY INDD(STDERR) OUTDD(STDERRPR) TEXT
/*
Example 2: A z/OS sequential data set transferred to a Unix file

In this example (SCPPUT from SAMPLIB), a specific translate table is used for code set translation and the source data set is defined using a DD card.

//SCPPUT EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=0M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCPPUT.out',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCPPUT.err',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDENV   DD  DSN=&SYSUID..SSZ.SRVR63.PARMLIB(SSHENV),
//             DISP=SHR
//PROGLI   DD  DSN=&SYSUID..TEST.C.LIST,
//             DISP=SHR
//SYSTSIN  DD  *
  BPXBATSL PGM /opt/tectia/bin/scpg3 +
        --src-site=E=STANDARD,A=___TCPIP.%T.TCPXLBIN,F=LINE +
        //DD:PROGLI +
        user1@remote_host:test_c.list
/*
//STDPR   EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=100,
//             REGION=0M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCPPUT.out',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCPPUT.err',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDOUTPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//STDERRPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//SYSTSIN  DD  *
  OCOPY INDD(STDOUT) OUTDD(STDOUTPR) TEXT
  OCOPY INDD(STDERR) OUTDD(STDERRPR) TEXT
/*
Example 3: A Unix file transferred to a z/OS sequential data set

In this example (SCPGET2 from SAMPLIB), the destination data set is defined and pre-allocated using a DD card.

//SCPGET2 EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=0M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCPGET2.out',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCPGET2.err',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDENV   DD  DSN=&SYSUID..SSZ.SRVR63.PARMLIB(SSHENV),
//             DISP=SHR
//TESTFI   DD  DSN=USER1.FILE.PS.TEST1,
//             DISP=(NEW,CATLG),
//             VOL=SER=Z6SYS1,
//             SPACE=(TRK,(2,2)),
//             DCB=(RECFM=VB,LRECL=1024,BLKSIZE=27998)
//SYSTSIN  DD  *
BPXBATSL PGM /opt/tectia/bin/scpg3 +
        user1@_remoteserver:textfile.txt +
        //DD:TESTFI
/*
//STDPR   EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=0M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCPGET2.out',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCPGET2.err',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDOUTPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//STDERRPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//SYSTSIN  DD  *
  OCOPY INDD(STDOUT) OUTDD(STDOUTPR) TEXT
  OCOPY INDD(STDERR) OUTDD(STDERRPR) TEXT
/*
Example 4: A Windows file transferred to a partitioned data set member

In this example (SCPGET3 from SAMPLIB), the remote file is transferred to mainframe as a PDS member. The FB80 profile defines the needed data set characteristics and code set translation.

//SCPGET3 EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=0M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCPGET3.out',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCPGET3.err',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDENV   DD  DSN=&SYSUID..SSZ.SRVR63.PARMLIB(SSHENV),
//             DISP=SHR
//SYSTSIN  DD  *
BPXBATCH PGM /opt/tectia/bin/scpg3 +
	      --dst-site=P=FB80,T=PDS +
        user1@_remoteserver:jcl.txt +
        //'USER1.JCLLIB(JCL1)
/*
//STDPR   EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=0M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCPGET3.out',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCPGET3.err',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDOUTPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//STDERRPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//SYSTSIN  DD  *
  OCOPY INDD(STDOUT) OUTDD(STDOUTPR) TEXT
  OCOPY INDD(STDERR) OUTDD(STDERRPR) TEXT
/*

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: Batch file transfer with two file transfers

In this example (SFTPBAT from SAMPLIB), sftpg3 is run in batch mode.

//SFTPBAT EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=0M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SFTPBAT.out',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDERR   DD  PATH='/tmp/&SYSUID.-SFTPBAT.err',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDENV   DD  DSN=&SYSUID..SSZ.SRVR63.PARMLIB(SSHENV),
//             DISP=SHR
//SYSTSIN  DD  *
  BPXBATCH PGM /opt/tectia/bin/sftpg3 +
        -B //'USER1.TRANSFER.BATCH' +
        user1@10.1.70.193
/*
//STDPR   EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=0M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SFTPBAT.out',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDERR   DD  PATH='/tmp/&SYSUID.-SFTPBAT.err',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDOUTPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//STDERRPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//SYSTSIN  DD  *
  OCOPY INDD(STDOUT) OUTDD(STDOUTPR) TEXT
  OCOPY INDD(STDERR) OUTDD(STDERRPR) TEXT
/*

File transfer commands in the batch file 'USER1.TRANSFER.BATCH' can be, for example, the following:

sput //FILE2.PS /home/user1/file1.dat
lsite LRECL=80
lsite RECFM=FB
sget files/jcl //'USER1.PDS(MEM1)'
Example 2: Batch file transfer without a separate batch file

In this example (SFTP from SAMPLIB), sftpg3 is run in batch mode and the batch commands are given in the same job using an inline file referenced by a DD name.

//SFTP    EXEC PGM=BPXBATSL,
//             REGION=0M,
//             PARM='PGM /opt/tectia/bin/sftpg3
//             -B //DD:BATCHIN'
//SYSTSPRT DD  SYSOUT=*
//STDOUT   DD  PATH='/tmp/&SYSUID.-sftpg3.out',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDENV   DD  DSN=&SYSUID..SSZ.SRVR63.PARMLIB(SSHENV),
//             DISP=SHR
//BATCHIN  DD  *
open REMUSER@remhost               1
cd //'SYS1.MACLIB'                 2
sget CALL /tmp/call-macro          3
site RECFM=FB                      4
site LRECL=80                      5
sput /tmp/call-macro //TEST.CALL   6
ls //TEST.CALL                     7
quit                               8
/*
//*
//PRINT   EXEC PGM=IKJEFT1A
//SYSTSPRT DD  SYSOUT=*
//STDOUT   DD  PATH='/tmp/&SYSUID.-sftpg3.out',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDOUTPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//SYSTSIN  DD  *
  OCOPY INDD(STDOUT) OUTDD(STDOUTPR) TEXT
/*

The sftpg3 batch commands do the following steps:

1

Connects to account REMUSER on the host remhost, which is an MVS machine running Tectia Server for IBM z/OS.

2

Changes to use SYS1.MACLIB as the "current directory".

3

Transfers a member into a HFS file.

4

Sets the data set organization.

5

Sets the record length.

6

Transfers the HFS file into a new MVS data set.

7

Makes sure the transfer is completed by listing the data set.

8

Ends the run.

===AUTO_SCHEMA_MARKUP===