sftp output is different when running manually/script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers sftp output is different when running manually/script
# 1  
Old 06-18-2010
sftp output is different when running manually/script

When I manually run a sftp to a remote server I receive the following output on he screen;

Code:
Uploading filename to /inbound/xxxxxxx_Folder_1/filename
                                                                                             filename                    100%   50     0.1KB/s   00:00

When I run the command within a shell script and pipe the output to a logfile, I do not get the "filename 100% 50 0.1KB/s 00:00" information. This is useful information, % completed and bytes transferred.

How can I get the information that is output when I do the command manually to get to my logfile when running the commands in the script?

The command I am running in the shell script is as follows:

Code:
sftp -vv -b $SFTPJOB -oIdentityFile=$KEYPATH/$KEYFILE `/bin/cat $KEYPATH/$CUSTOMER/$AUTHFILE`@$HOST >> $LOGFILE 2>&1

Thank you.

Last edited by Scott; 06-18-2010 at 04:40 PM.. Reason: Please use code tags
# 2  
Old 06-18-2010
You've got the right idea capturing stderr, but I think you need to put the 2>&1 before you redirect stdout into $LOGFILE.

[edit] It accepts a specific command to toggle the progress bar on/off, too: progress. It may turn it off by default when it's running uninteractively. Beware that with it on, your logfile will probably capture all progress messages, not just the last one. That could be hundreds or thousands of lines on a long transfer.

Last edited by Corona688; 06-18-2010 at 05:11 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with running script at sftp

Hello All, I am trying to run a sftp batch script (.conf) file from a shell script. I wanted to remove a file from sftp if it exists else it should ignore removing and continue with other commands in .conf file. I am not able to put logic in .conf file.Any idea how that can be achieved. ... (2 Replies)
Discussion started by: sp92
2 Replies

2. Shell Programming and Scripting

Why my git command has no output in crontab but works well run this script manually?

cat /home/lyang001/update.sh #!/bin/sh #shopt -s expand_aliases HOME_DIR=/home/lyang001/updates UPDATE_MAIL=${HOME_DIR}/updates.mail rm $UPDATE_MAIL -rf cd $HOME_DIR/wr-kernel git log --no-merges --since="20 day ago" --name-status --pretty=format:"%an %h %s %cd" origin/WRLINUX_5_0_1_HEAD >>... (2 Replies)
Discussion started by: yanglei_fage
2 Replies

3. Shell Programming and Scripting

Output differs when run manually and when cron job executes it

I get a different output when i manually run the .sh script and when it is run by a cron job. Please help me .. TMP1="/lhome/bbuser/script/wslog/sar.t1" TMP2="/lhome/bbuser/script/wslog/sar.t2" TMP3="/lhome/bbuser/script/wslog/sar.t3" OUTPUT="/lhome/bbuser/script/wslog/sar.out"... (8 Replies)
Discussion started by: nithinankam
8 Replies

4. Shell Programming and Scripting

Part of the Shell script is not running via crontab, runs fine manually

Hello Team, As a part of my job we have made a script to automate a service to restart frequently. Script having two functions when executing it's should find the existing service and kill it, then start the same service . Verified the script it's working fine when executing... (18 Replies)
Discussion started by: gowthamakanthan
18 Replies

5. Shell Programming and Scripting

cronjob not running but runs manually

hello, i recently switched to a new ec2 box and transferred the cronjobs from the old box. For some reason one of the scripts won't work but it runs manually from the command line. I've read from previous threads it might be an environment issue but I added a line with the path to the script... (2 Replies)
Discussion started by: lencholamas
2 Replies

6. Shell Programming and Scripting

Getting issue while running it from cron while manually working fine

Hello, I am working one one script where I am using the below code which is using to connect with MKS client when I run my script manually it works effiecently i.e. it connects with MKS client but when I run it from CRON it doesn't connect. 1)Can some one tell when it is running from cron... (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

7. Shell Programming and Scripting

Running a script in system() call and want the script's output

Hi All, I have a script(sample.sh) displaying the output of "dd" command. Now i am using this script in system() call as, system("sh sample.sh") in an application file. I want the output of system("sh sample.sh") in the application file itself. How can i get it? Many thnaks.... (9 Replies)
Discussion started by: amio
9 Replies

8. Shell Programming and Scripting

sftp output is different when running manually/script

When I manually sftp a file to a remote server I get the following output on the screen; Uploading filename to /inbound/xxxxxxx_Folder_1/filename filename 100% 50 0.1KB/s 00:00 When I run the commands from within a shell script I do not get the "filename ... (0 Replies)
Discussion started by: rugggy
0 Replies

9. UNIX for Dummies Questions & Answers

Running script on SFTP server, RMDIR and RM with wildcards

Im going insane trying to figure out what i consider a basic command on an SFTP server... Im trying to download all files from a directory *done* then remove all the files (and sometimes folders that contain files) i have downloaded on the remote directory... the command i would normally... (2 Replies)
Discussion started by: mokachoka
2 Replies

10. Solaris

SFTP errorcode 1 when run on cron but runs manually

I am trying to run a sript on cron to SFTP data to a company. Private and public keys are set up. When I run this manully it works fine, however it was failing when run on cron. I have narrowed down the problem - it fails at the code that says if the error code is 0 then continue . . . I... (2 Replies)
Discussion started by: Heidi.Ebbs
2 Replies
Login or Register to Ask a Question