Automated SFTP script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automated SFTP script
# 1  
Old 01-21-2008
Automated SFTP script

Hi All,

I am writing an automated SFTP script to xfer files. I am able to do sftp in batch mode and it is working absolutely fine.
The problem is that on redirecting the output of SFTP session to some file, it is not writing about the status of SFTP operation. All i can see in output file is :

sftp> put file2.dst2
Uploading file2.dst2 to /data05/FTP_test/dst2/file2.dst2

Whereas in interactive mode the output is :-

sftp> put file2.dst2
Uploading file2.dst2 to /data05/FTP_test/dst2/file2.dst2 file2.dst2 100% 4096 4.0KB/s 00:00

I need to know the status of the SFTP operation so as to rename the files successfully xferred...

Am i missing anything here ?? Please help..
# 2  
Old 01-21-2008
When running in batch mode, I don't think you have a way to catch the exit code of each operation. Instead, you can redirect everything to a log file and later grep for certain patterns like "fatal, error, couldn't" etc.
# 3  
Old 01-22-2008
I am doing exactly that... but the log file is not writing anything after

Uploading file2.dst2 to /data05/FTP_test/dst2/file2.dst2

Is is normal sftp behaviour or am i missing something ??
# 4  
Old 01-22-2008
That's normal, I'm usually using "nohup" in front of every ssh transfer, the STDOUT by default gets redirected to file called "nohup.out" and then I look at this file, but I'm not sure if this is going to work in batch mode.
# 5  
Old 01-31-2008
you might consider using the FTCL scripting language .. supports FTP/S and SFTP and allows you to send debug information to a file.

Secure FTP Factory - Java SFTP, Java Secure FTP, Java FTPS, Java FTP, FTP SSL, FTP SSH
# 6  
Old 02-21-2008
I would say if you are scripting SFTP sessions, you should not use SFTP as your client program, but a generic FTP program called LFTP (LFTP - sophisticated file transfer program) using an SSH/SFTP protocol. Covers all sorts of FTP-ish protocols and has great shell scripting support
# 7  
Old 08-05-2008
hi aggar_y
i am trying to implement the SFTP script in solaris. could you please send me the snippet of the code which is working for you?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automated passwd protected sftp

I am trying to automate the process using password protected sftp upload the file in daily basis from our server to client server and exit successfully from remote server Getting issue while running the script. sftp test@12.342.564.205/passwd--password for sftp cd /home/group/jagu/txt put... (3 Replies)
Discussion started by: jagu
3 Replies

2. Shell Programming and Scripting

Need an automated script

Hi, I need a script to execute below task. As of now I am doing it manually and want it automated. 1)go to below path cd /path/of/file check for the availibility of two file as below of the latest date. Case1. If above files are not present... (3 Replies)
Discussion started by: sv0081493
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@ The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

4. Shell Programming and Scripting

Automated log script

Hello, I am scripting noob but I need little monitoring script. It will be very good if you can help me. What I need: Script will login via ssh to another machine (ssh -l user ipadress), make top command and log first row + machine ip. It should monitor like 10 machines. Script should run... (1 Reply)
Discussion started by: Biosko
1 Replies

5. Shell Programming and Scripting

sftp automated script

HI, Can anyone has automated sftp script? I want to upload one file from one server to other. Could anyone help us? (3 Replies)
Discussion started by: javeed7
3 Replies

6. UNIX for Advanced & Expert Users

scp automated script

Hi Unix gurus, I am trying to create a script to automate the copying of files daily from one server to another using the scp command. --> #!/bin/ksh KEY="$HOME/.ssh/SSHKEY" if ;then echo "Private key not found at $KEY" >> $LOGFILE echo "* Please create it with \"ssh-keygen -t dsa\" *"... (5 Replies)
Discussion started by: gholdbhurg
5 Replies

7. Shell Programming and Scripting

i want automated script

echo "Enter your choice :\c" read num case $num in . 1)"${TEST_HOME}"/ctrl_extract.ksh 1 ;; 2)"${TEST_HOME}"/ctrl_extract.ksh 2 ;;3)"${TEST_HOME}"/ctrl_extract.ksh 3 ;; 4)"${TEST_HOME}"/ctrl_extract.ksh 4 ;; 5)"${TEST_HOME}"/ctrl_extract.ksh 5 ;;... (3 Replies)
Discussion started by: arghya_owen
3 Replies

8. Shell Programming and Scripting

automated sftp script

Ok, I am sure this has been beat like a dead horse, but I an trying "anew". I am trying to create a script that will automate a file transfer using sftp. Please, I am at rock bottom. Thank you. (2 Replies)
Discussion started by: klindel
2 Replies

9. Shell Programming and Scripting

automated sftp procedure interrupted

Dear experts, I have a local computer and remote computer (only sftp accessed). I want to delete files x and y in both local and remote computer using the following automated script: sftp $remote > /dev/null < mdel.file the file mdel.file has been pre-created, and its content is cd... (2 Replies)
Discussion started by: boyin.huang
2 Replies

10. UNIX for Advanced & Expert Users

help for automated script

Hi ALL: I need to write a script that will start bunch of servers. and these servers each has a sudo account and they need a passowrd. I dont know where to start and look. Can you please give me some hints or some sample code. Thanks in advance. splax (4 Replies)
Discussion started by: splax
4 Replies
Login or Register to Ask a Question