Question about SFTP command

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Question about SFTP command
# 1  
Old 11-24-2017
Question about SFTP command

Hi All,

This is JCL that contain command script to copy file to destionation (UNIX)
I have 2 questions.

*********
Code:
//NATTOUT1 JOB ACCL,'XXXXYYYY',CLASS=A,MSGCLASS=X,                                 
//  NOTIFY=&SYSUID,REGION=0M,USER=SFTPXXX                                         
// SET PATH='/BBBB/XYX'                                                           
// SET USR='NATTNATT001'                                                           
//*****************************************************************               
//COPYOUT  EXEC PGM=IKJEFT01,DYNAMNBR=300,COND=EVEN                               
//*****************************************************************               
//SYSTSPRT DD SYSOUT=*                                                             
//DSIN     DD DSN=NNNN.FIX.LENGTH.OUTFILE,DISP=SHR                             
//HFSOUT   DD PATH='&PATH/CXCXS',                                                 
// PATHOPTS=(OCREAT,OTRUNC,OWRONLY),PATHMODE=SIRWXU                               
//SYSPRINT DD SYSOUT=*                                                             
//SYSTSIN  DD DATA,DLM='/>'                                                       
OCOPY INDD(DSIN) OUTDD(HFSOUT) BINARY                                             
/>                                                                                 
//CMDS     EXEC PGM=IKJEFT01                                                       
//INMVS    DD *                                                                   
cd /NATTNATT001/NATTNATT003/NAT0007IN                                             
pwd                                                                               
ls                                                                                 
put /BBBB/XYX/CXCXS VTESTX.TXT                                                     
!rm CXCXS                                                                         
!rm sftp.cmds                                                                     
!rm sftp1.sh                                                                       
quit                                                                               
//OUTHFS   DD FILEDATA=TEXT,                                                       
//            PATHOPTS=(OWRONLY,OCREAT,OTRUNC),                                   
//            PATHMODE=SIRWXU,                                                     
//            PATH='&PATH/sftp.cmds'                                               
//SYSTSIN  DD *                                                                   
  OCOPY IND(INMVS) OUTDD(OUTHFS)                                                   
/*                                                                                 
//SYSTSPRT DD SYSOUT=*                                                             
//SYSPRINT DD SYSOUT=*                                                             
//* create sftp shell script                                                       
//SH       EXEC PGM=IKJEFT01                                                       
//INMVS    DD *                                                                   
sftp -b sftp.cmds -oPort=4321 -oStrictHostKeyChecking=no $1@$2                     
//OUTHFS   DD FILEDATA=TEXT,                                                       
//            PATHOPTS=(OWRONLY,OCREAT,OTRUNC),                                   
//            PATHMODE=SIRWXU,                                                     
//            PATH='&PATH/sftp1.sh'                                               
//SYSTSIN  DD *                                                                   
  OCOPY IND(INMVS) OUTDD(OUTHFS)                                                   
//SYSTSPRT DD SYSOUT=*                                                             
//SYSPRINT DD SYSOUT=*                                                             
//*                                                                               
//UPLOADFL EXEC PGM=VCXBATCH,                                                     
//  PARM='sh  cd &PATH;./sftp1.sh &USR 999.999.999.99'                             
//STDOUT   DD  SYSOUT=*                                                           
//STDERR   DD  SYSOUT=*                                                           
//SYSOUT   DD SYSOUT=*

***************************

1. Why we can create path to destination before we sign in to destination?
or it just create command and at the end just execute step?

2. If I would like to run this JCL by myself, I need to create the folder path in testing server ?

I run it myself but found error like this

Code:
IEF344I NATTOUT1 COPYOUT HFSOUT - ALLOCATION FAILED DUE TO DATA FACILITY SYSTEM ERROR
IGD17501I ATTEMPT TO OPEN A HFS FILE FAILED,                                   
RETURN CODE IS (00000081) REASON CODE IS (0594003D)                           
FILENAME IS (/BBBB/XYX/CXCXS)                                                 
IEF272I NATTOUT1 COPYOUT - STEP WAS NOT EXECUTED.

Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, output, and code segments (as required by the rules you agreed to when joining this forum.)

Thank you very much

Last edited by Don Cragun; 11-24-2017 at 09:53 PM.. Reason: Add CODE tags.
# 2  
Old 11-25-2017
1. Set the home directory of the unix user to the destination directory.
2. Not if the directory exists, and you have write permission.
Code:
put /BBBB/XYX/CXCXS VTESTX.TXT  
!rm CXCXS

This does not appear to be correct. Based on the put statement, the script is not running in the directory that contains the filef that you want to delete.
also i would not delete the source file until the transferred file has been processed.

Last edited by jgt; 11-25-2017 at 05:29 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sftp ls command

Hi Team, i need to capture the file creation date and time ,but i tried ls -l only working . Cloud please help me to display year month data and time. Thanks, Murali (1 Reply)
Discussion started by: bmk123
1 Replies

2. Shell Programming and Scripting

SFTP Command

Hi Freinds, I need to transfer the files from the Remote server using SFTP. While i transfer the file, the time stamp of the file need not to be changed. Ineed to transfer the file as without change in its time stamp. Is the any option or commands available. pl let me know... Regards,... (3 Replies)
Discussion started by: C_PRASANNA
3 Replies

3. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

4. Shell Programming and Scripting

Yet another sftp automation question

Hello, I've read quite a few of the sftp questions and answers on the forum but I believe my situation is slightly different. I need to automate an sftp transfer to a host that requires not only a ssh publickey, but also a password. When I try using sftp in batch mode, supplying a "user... (4 Replies)
Discussion started by: n3llyb0y
4 Replies

5. UNIX and Linux Applications

Question concerning enterprise ftp/sftp solutions

Would any of you have any good experiences, recommendations here. We are basically looking for a one stop solution for ftp/sftp including key and encryption management. FTP/S and any HA functionality would be a great bonus. Cheers! (1 Reply)
Discussion started by: Eronysis
1 Replies

6. Shell Programming and Scripting

sftp command

Hello folks i want to know hoaw can i automate sftp command. When i am execute the script it sftp connect to host and ask for the password but i want password also to be supplied in batfile .It should not ask password on console . sftp -b batfile user@hostip (4 Replies)
Discussion started by: kojo
4 Replies

7. Solaris

SFTP log question

On a Sun Solaris 9 box, how do I know what kind of SFTP server is running? And, if someone sftp'ed a file to my box, where is the log file I can check if the sftp session was a successful one or not? (1 Reply)
Discussion started by: fld2007
1 Replies

8. Solaris

SFTP file format question

Hi, We here at State of Iowa are trying to SFTP an ascii text file off of an IBM server over to our DOL SUN Server using Solaris 5.8. After doing the secure handshake login all I am doing at present is "sftp> get testfile". Somehow in pulling the file in from the IBM server to the SUN server it... (2 Replies)
Discussion started by: wsiefkas
2 Replies

9. UNIX for Dummies Questions & Answers

Question about Openssh and sftp

I have to create an automated sftp job on an AIX box. The sftp command doesnt work. Do I need to install the openssh package in order to be able to invoke the sftp command? (2 Replies)
Discussion started by: NycUnxer
2 Replies

10. Shell Programming and Scripting

SFTP file transfer mode question

I am having trouble viewing a file in ASCII after doing a 'get' using SFTP. It appears to have come across as machine language. Does the file have to be in ASCII format prior to the 'get' or is there a way to convert it to ascii after I get it onto my server? I have read where the secure file... (0 Replies)
Discussion started by: wsiefkas
0 Replies
Login or Register to Ask a Question