Your browser does not allow this site to store cookies and other data. Some functionality on this site may not work without them. See Privacy Policy for details on how we would use cookies.

SSH Tectia

Unattended File Transfers

Unattended file transfers of MVS datasets 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 dataset

This example (SCPGET from SAMPLIB) executes scpg3 and copies a remote file textfile.txt into a dataset //'USERID.TEST.TEXTFILE'. If the dataset 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=6M
//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.SRVR60.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=6M
//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 dataset transferred to a Unix file

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

//SCPPUT EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=6M
//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.SRVR60.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=6M
//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 dataset

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

//SCPGET2 EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=6M
//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.SRVR60.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=6M
//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 dataset member

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

//SCPGET3 EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=6M
//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.SRVR60.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=6M
//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=6M
//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.SRVR60.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=6M
//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.

The sftpg3 batch commands do the following steps:

  1. Connects to account REMUSER on the host remhost.

    remhost is an MVS machine running SSH 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 dataset organization and record length.

  5. Transfers the HFS file into a new MVS dataset.

  6. Makes sure the transfer is completed by listing the dataset.

  7. Ends the run.

//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.SRVR60.PARMLIB(SSHENV),
//             DISP=SHR
//BATCHIN  DD  *
open REMUSER@remhost
cd //'SYS1.MACLIB'
sget CALL /tmp/call-macro
site RECFM=FB
site LRECL=80
sput /tmp/call-macro //TEST.CALL
ls //TEST.CALL
quit
/*
//*
//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
/*

===AUTO_SCHEMA_MARKUP===