Any suggestion on Capturing SFTP error in log ???


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Any suggestion on Capturing SFTP error in log ???
# 1  
Old 08-15-2008
Any suggestion on Capturing SFTP error in log ???

Hello All,

I have searched the thread for capturing and got some suggestion but that is not working for me.

I am trying to sftp to a window server from unix server and getting file there with out any issue .But i wan't to capture the error --in case a file is not exist in remote.

Example :
I tried the script following way
1) cat sftp_transfer.ksh

2>&1
sftp -b trfr_Files.sftp servername

2) cat sftp_transfer.ksh

sftp -b trfr_Files.sftp servername >error.sftp


==========
Surprisingly in both the case the error is not redirecting to the file .
In second part only success full file transfer are recorded in logfile but not error.
When ever some file is not present it is straight way throwing the error to the STDOUT.

$ ./sftp_transfer.ksh
Error :

Couldn't stat remote file: No such file or directory
File "/logs/test//xxxx_172.18.127.2_20080526.txt1" not found.

Any suggestion how to redirect the erro part or all of the output and error to a logfile .

***Note the trfr_Files.sftp contain the list of get file from the server****
Script working fine only thing i am not able to redirect the error part to a log.
# 2  
Old 08-15-2008
Code:
sftp -b trfrOriginFiles.sftp servername 2>error.sftp

or if you want both regular output and error messages in the same file

Code:
sftp -b trfrOriginFiles.sftp servername >error.sftp 2>&1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capturing error codes in SFTP commands

Hi, I have been using the SFTP commands in my reusable shell scripts to perform Get/Put operation. The script has a list of 6 errors which i am capturing through the log file using grep command. But I feel there might me more errors which the script might need to capture. I tried to capture the... (2 Replies)
Discussion started by: Bobby_2000
2 Replies

2. Shell Programming and Scripting

How to Log No Connect Error and then Exit using SFTP?

Solaris 10 9/10 BASH using the following code snippet: sftp $TOHOST <<RESULT cd /inbound/ lcd /transfer put $i bye I want to log no server connections and the kill the script after the log entry was made. How would I do... (2 Replies)
Discussion started by: os2mac
2 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

SQLPLUS Error Capturing

This is my .sh file sqlplus -s my_user/my_pswd@mydb @my_sql.sql ret_code=$? if then echo "return code is $ret_code " echo "Failed" else echo "return code is $ret_code " echo "Success" fi ===================================================== and my_sql.sql is whenever... (4 Replies)
Discussion started by: emailsafath2011
4 Replies

5. Shell Programming and Scripting

Capturing errors messages into log file

Can we capture and write all the error messages which were being displayed on the command prompt screen during execution of a program into a log file? If yes, can anyone please let me know on how to do it? I am using ksh and working on AIX server. Thank you in advance. (4 Replies)
Discussion started by: vpv0002
4 Replies

6. Red Hat

Help for capturing a URL from a line from large log file

Can someone please help me how do I find a URL from lines of log file and write all the output to a new file? For e.g - Log file has similar entries, 39.155.67.5 - - "GET /abc/login?service=http://161.120.36.39/CORPHR/TMA2007/default.asp HTTP/1.1" 401 3218 54.155.63.9 - - "GET... (2 Replies)
Discussion started by: rockf1bull
2 Replies

7. Shell Programming and Scripting

Capturing script output and input to log

Hi Is there a way that I can capture a shell script (both output and input) to a log file where I can analyze it? Thanks (6 Replies)
Discussion started by: nimo
6 Replies

8. Shell Programming and Scripting

Capturing log of a shell script

Hi, I have a script which does multiple tasks in sequence. When i execute the script, it runs and displays lot of messages for each of the steps on the console. Is there any way I can capture those messages and store it for audit purposes ? Best Regards, bornon2303 (2 Replies)
Discussion started by: bornon2303
2 Replies

9. UNIX for Dummies Questions & Answers

Capturing FTP log

I am trying to do the FTP using .netrc.In my .netrc file in $HOME dir i am placing the machine ip,user name and pwd.Then i am creating dynamically a file which contains the ftp commands. My script is like below: __________________________________ export REMOTE_DIR= <some path> export... (4 Replies)
Discussion started by: dr46014
4 Replies

10. Shell Programming and Scripting

capturing log

Hi below is my script which copies test file to each directory in the file and checks if the permissions are ok, but I am not able to capture the log of the output. here is the script #! /usr/bin/sh set -x cd /dir/of/files while read line do cp test.txt $line rm $line/test.txt done <... (3 Replies)
Discussion started by: mgirinath
3 Replies
Login or Register to Ask a Question