SSH on iSeries to encrypted file transfer

15 pts.
Tags:
File transfers
iSeries
SSH
I am looking for a sample CL program that use SSH to transfer file to another server, any help will be greatly appreciated! I've already establised the system i ssh client and user profile. I am looking for CLP programming that will run on daily basis to transfer the files. Thank you

Answer Wiki

Thanks. We'll let you know when a new response is added.

Here’s my clp which I put on the job scheduler which runs it daily at 3pm central time. This clp gets a file from a bank and downloads file to the AS/400 IFS. Obviously it will have to be modified.

5722SS1 V5R4M0 060210 Control Language WEBLIB/MOD001CL OTTAWA 08/25/09 09:33:17 Page 1
Program . . . . . . . . . . . . . . . . . . . : MOD001CL
Library . . . . . . . . . . . . . . . . . . : WEBLIB
Source file . . . . . . . . . . . . . . . . . : QCLSRC
Library . . . . . . . . . . . . . . . . . . : WEBLIB
Source member name . . . . . . . . . . . . . : MOD001CL 03/19/09 20:51:23
Source printing options . . . . . . . . . . . : *SOURCE *XREF *GEN *NOSECLVL *NOSRCDBG *NOLSTDBG
Program generation options . . . . . . . . . : *NOLIST *NOXREF *NOPATCH
User profile . . . . . . . . . . . . . . . . : *USER
Program logging . . . . . . . . . . . . . . . : *JOB
Allow RTVCLSRC command . . . . . . . . . . . : *YES
Replace program . . . . . . . . . . . . . . . : *YES
Target release . . . . . . . . . . . . . . . : V5R4M0
Authority . . . . . . . . . . . . . . . . . . : *LIBCRTAUT
Sort sequence . . . . . . . . . . . . . . . . : *HEX
Language identifier . . . . . . . . . . . . . : *JOBRUN
Text . . . . . . . . . . . . . . . . . . . . : OpenSSH batch mode file transfers using SFTP
Compiler . . . . . . . . . . . . . . . . . . : IBM Control Language Compiler
Control Language Source
SEQNBR *…+… 1 …+… 2 …+… 3 …+… 4 …+… 5 …+… 6 …+… 7 …+… 8 …+… 9 …+. DATE
100- PGM 02/23/09
200- 02/23/09
300- /* UNATTENDED SFTP USING PUBLIC KEY AUTHENTICATION WITHOUT A */ 02/23/09
400- /* PASSPHRASE. */ 02/23/09
500- 02/23/09
600- /* THE FOLLOWING CLP LOGS SUCCESS OR FAILURE IN OPENSSH BATCH */ 02/23/09
700- /* MODE FILE TRANSFERS. */ 02/23/09
800- 02/23/09
900- /* THE CONTENTS OF THE RC VARIABLE WILL BE STORED IN SPOOL */ 02/23/09
1000- /* FILE QPPGMDMP WHICH CAN BE FOUND IN QEZDEBUG OUTPUT QUEUE. */ 02/23/09
1100- 02/23/09
1200- /* THE INPUT FILE IS STORED ON THE IFS */ 02/23/09
1300- /* PATH: /HOME/CESOTWA1/SFTPCMD.TXT */ 02/23/09
1400- /* THIS FILE WAS CREATED IN NOTEPAD ON THE PC AND OPS NAVIGATOR */ 02/23/09
1500- /* WAS USED TO PUT THE FILE ON THE IFS */ 02/23/09
1501- 02/23/09
1600- DCL VAR(&RC) TYPE(*INT) LEN(4) 02/23/09
1700- DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) 02/23/09
1800- DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(4) 02/23/09
1900- DCL VAR(&CM3) TYPE(*CHAR) LEN(400) 02/23/09
2000- DCL VAR(&CM31) TYPE(*CHAR) LEN(20) + 02/23/09
2100 VALUE(‘/QOpenSys/bin/sftp ‘) 02/23/09
2200- DCL VAR(&CM32) TYPE(*CHAR) LEN(31) VALUE(‘-b + 02/23/09
2300 /home/cesotwa1/sftpcmd.txt ‘) 02/23/09
2400- DCL VAR(&CM33) TYPE(*CHAR) LEN(26) + 02/23/09
2500 VALUE(SFTP.MODPAY.COM) 02/23/09
2600- CHGVAR VAR(&CM3) VALUE(&CM31 *CAT &CM32 *CAT &CM33) 02/23/09
2700- QSH CMD(&CM3) 02/23/09
2800- 02/23/09
2900- /* CHECK FOR SFTP ERRORS */ 02/25/09
3000- RCVMSG MSGTYPE(*COMP) RMV(*NO) MSGDTA(&MSGDTA) + 02/23/09
3100 MSGID(&MSGID) 02/23/09
5722SS1 V5R4M0 060210 Control Language WEBLIB/MOD001CL OTTAWA 08/25/09 09:33:17 Page 2
Control Language Source
SEQNBR *…+… 1 …+… 2 …+… 3 …+… 4 …+… 5 …+… 6 …+… 7 …+… 8 …+… 9 …+. DATE
3500- IF COND(&MSGID *EQ ‘QSH0005′) THEN(CHGVAR + 02/23/09
3600 VAR(&RC) VALUE(%BIN(&MSGDTA))) 02/23/09
3700- DMPCLPGM /* DUMP WILL SHOW RC AS 0 (SUCCESS) OR 1-255 + 02/23/09
3800 (FAIL) */ 02/23/09
3900- 02/23/09
4000- IF COND(&MSGID *NE ‘QSH0005′ *OR %BIN(&MSGDTA) + 02/23/09
4100 *NE 0) THEN(DO) 02/23/09
4200- SNDPGMMSG MSGID(CPF9897) MSGF(QCPFMSG) MSGDTA(‘SFTP + 02/23/09
4300 SCRIPT FAILED!’) MSGTYPE(*ESCAPE) 02/23/09
4400- ENDDO 02/23/09
7602- 02/23/09
8800- /* NOW WE WILL COMBINE ALL THE FILES DOWNLOADED INTO ONE FILE */ 02/23/09
8900- /* ON THE IFS “COMBINE.TXT” */ 02/23/09
8901- /* DOWNLOADED FILES WILL BE APPENDED TO THE COMBINE.TXT FILE */ 03/19/09
8902- /* DUE TO THE “>>” WHICH SAYS APPEND/ADD TO THE FILE AND NOT */ 03/19/09
8903- /* REPLACE THE CONTENTS. */ 03/19/09
8904- /* IF YOU WANT TO REPLACE CHANGE THE “>>” TO “>” */ 03/19/09
8905- 02/23/09
9000- QSH CMD(‘cat /home/ModernPayments/Input/*.txt >> + 03/19/09
9100 /home/ModernPayments/Output/Combine.txt’) 03/19/09
9101- 02/23/09
10300- /* DELETE ALL INPUT FILES */ 02/23/09
10301- 02/23/09
10400- QSH CMD(‘rm /home/ModernPayments/Input/*.txt’) 02/23/09
11001- 02/23/09
25700- ENDPGM 02/23/09
* * * * * E N D O F S O U R C E * * * * *
5722SS1 V5R4M0 060210 Control Language WEBLIB/MOD001CL OTTAWA 08/25/09 09:33:17 Page 3
Cross Reference
Declared Variables
Name Defined Type Length References
&CM3 1900 *CHAR 400 2600 2700
&CM31 2000 *CHAR 20 2600
&CM32 2200 *CHAR 31 2600
&CM33 2400 *CHAR 26 2600
&MSGDTA 1800 *CHAR 4 3000 3500 4000
&MSGID 1700 *CHAR 7 3000 3500 4000
&RC 1600 *INT 4 3500
* CPD0791 00 No labels used in program.
* * * * * E N D O F C R O S S R E F E R E N C E * * * * *
5722SS1 V5R4M0 060210 Control Language WEBLIB/MOD001CL OTTAWA 08/25/09 09:33:17 Page 4
Message Summary
Severity
Total 0-9 10-19 20-29 30-39 40-49 50-59 60-69 70-79 80-89 90-99
1 1 0 0 0 0 0 0 0 0 0
Program MOD001CL created in library WEBLIB on 08/25/09 at 09:33:18.
Program MOD001CL created in library WEBLIB. Maximum error severity 00.
* * * * * E N D O F M E S S A G E S U M M A R Y * * * * *
* * * * * E N D O F C O M P I L A T I O N * * * * *

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Victorycr3027
    This is really great help. I am going to modify as per my requirement and will let you know soon about the progress. God bless you.
    15 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following