You are currently on IBM Systems Media’s archival website. Click here to view our new website.

IBM i > ADMINISTRATOR > SYSTEMS MANAGEMENT

sFTP Tips

What you need to know for easy and secure file transfers



 

sFTP Return Code

Using sFTP in QShell is handy. You can run the sFTP commands in batch easily, and use script files and logging output. However, you may want to include the QSH command in a CL program as part of a job stream. If you do, you probably need to know if sFTP completed successfully. You could examine the verbose debugging log, but that would be time consuming and difficult to automate.

However, sFTP can return a return code when the sFTP command is completed. I believe this capability is part of i 6.1, and PTFs in version V5R3 (SI25208) and V5R4 (SI25209) for 5733-SC1 provide this capability. It’s easy to use the return code capability. Here’s a short CL program to demonstrate:

PGM
DCL     VAR(&RC) TYPE(*INT) LEN(4)
DCL     VAR(&MSGDTA) TYPE(*CHAR) LEN(4)
DCL     VAR(&MSGID) TYPE(*CHAR) LEN(7)

QSH CMD('/QOpenSys/usr/bin/sftp  -vvv -b /Script/put_script.txt
    RMTUSER@commpartner.com > /logs/put_logoutput.txt 2>&1')

RCVMSG  MSGTYPE(*COMP) RMV(*NO) MSGDTA(&MSGDTA) +
    MSGID(&MSGID)

CHGVAR VAR&RC) VALUE(0)
IF      COND(&MSGID *EQ 'QSH0005') THEN(CHGVAR +
    VAR(&RC) VALUE(%BIN(&MSGDTA)))
IF COND(&RC *NE 0) THEN(DO)
  /* Error processing */
ENDDO

This program checks the return code after the sFTP command executed. If the return code is anything except zero, an error occurred.

sFTP Basics and Tips

There’s much more to sFTP, but I hope you can use this as a start for sFTP processing. Remember these items:

  • Permissions on the home directory
  • Case of the user name
  • OpenSSH vs. SSH2
  • Verbose debugging
  • Running sFTP in batch
  • Executing sFTP from QShell
  • Return codes

sFTP is a valuable tool being used by financial institutions and other communications partners. While some potential problems exist, sFTP is easy to configure and use.

 

Michael Ryan is a technical editor with IBM Systems Magazine. Michael can be reached at michael@ryantechnology.com.



Advertisement

Advertisement

2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

IBM i > ADMINISTRATOR > SYSTEMS MANAGEMENT

Going Mobile With DB2 Web Query

IBM i > ADMINISTRATOR > SYSTEMS MANAGEMENT

Directing i

How to enable IBM i for management by IBM Systems Director

IBM i > ADMINISTRATOR > SYSTEMS MANAGEMENT

Putting the "V" in Virtualization

IBM eServer line delivers on the promise of virtualization

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters