LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-26-2010, 03:12 AM   #1
Vilius
Member
 
Registered: Jan 2006
Location: Lithuania
Distribution: Arch, Debian
Posts: 193

Rep: Reputation: 16
sftp output to file ?


Hello,

I want to log sftp get command output:
Code:
sftp> get file3
Fetching /home/user1/file3 to file3
/home/user1/file3                                 100%   19     0.0KB/s   00:00
sftp>
If I do it with redirect operator I get:
Code:
sftp -b ./commands1 vldebitc100 >> kk.log
$
$ cat kk.log
sftp> get file3
Fetching /home/aixcronb/file3 to file3
sftp> quit
As you can see that second get command output line(which includes some statistics) is gone.
Any way to include that statistics line into my log ?


thanks
Vilius

Last edited by Vilius; 11-26-2010 at 03:15 AM.
 
Old 11-26-2010, 03:44 AM   #2
JoshyJ
Member
 
Registered: Nov 2003
Location: Sydney , Australia
Distribution: Fedora
Posts: 49

Rep: Reputation: 1
If you are just trying to create logs of what you do.

You can use the 'script' command. It will log anything after you start it with 'script -a outputfilename'. And you stop logging with a 'exit'.

Though this will log everything including the prompts. You can give it a try to see if it does log the stats also.

Last edited by JoshyJ; 11-26-2010 at 03:47 AM.
 
Old 11-26-2010, 03:52 AM   #3
Vilius
Member
 
Registered: Jan 2006
Location: Lithuania
Distribution: Arch, Debian
Posts: 193

Original Poster
Rep: Reputation: 16
Just tried that - statistics line is still missing:
Code:
-bash-3.2$ cat kkk.log
Script command is started on Fri Nov 26 11:49:23 GMT+02:00 2010.
sh-3.2$
sh-3.2$ sftp -b ./commands1 vldebitc100
sftp> get file3
Fetching /home/aixcronb/file3 to file3
sftp> quit
sh-3.2$ exit
exit

Script command is complete on Fri Nov 26 11:49:53 GMT+02:00 2010.
 
Old 11-26-2010, 04:26 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Did you add the progress option in your commands1 file? This explicitly turns on the progress meter.

This seems to work on my side:
Content of commands1:
Code:
progress
cd /data/Downloads
get opera-11.00-1111.i386.linux.tar.bz2
quit
Run commands (with script): script -qc "sftp -b commands user@host" output.log

Content of output.log:
Code:
$ cat output.log 
Script started on Fri Nov 26 11:22:58 2010
sftp> progress
Progress meter enabled
sftp> cd /data/Downloads
sftp> get opera-11.00-1111.i386.linux.tar.bz2
Fetching /data/Downloads/opera-11.00-1111.i386.linux.tar.bz2 to opera-11.00-1111.i386.linux.tar.bz2
/data/Downloads/opera-11.00-1111.i386.linux.t 100%   11MB  10.6MB/s   00:00    
sftp> quit
Hope this helps.
 
Old 11-26-2010, 04:57 AM   #5
Vilius
Member
 
Registered: Jan 2006
Location: Lithuania
Distribution: Arch, Debian
Posts: 193

Original Poster
Rep: Reputation: 16
Thanks druuna this was exactly what I was missing !!!!!!!!!!!!!!!1
 
Old 11-26-2010, 04:58 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You're welcome
 
Old 06-14-2016, 04:22 PM   #7
lnunezr
LQ Newbie
 
Registered: Jun 2016
Posts: 1

Rep: Reputation: Disabled
Unhappy Same problem with KSH

Hi: I have the same problem using ksh and the "Script -qc" command does not work. Could anyone help me?
Thanks!



Quote:
Originally Posted by druuna View Post
Hi,

Did you add the progress option in your commands1 file? This explicitly turns on the progress meter.

This seems to work on my side:
Content of commands1:
Code:
progress
cd /data/Downloads
get opera-11.00-1111.i386.linux.tar.bz2
quit
Run commands (with script): script -qc "sftp -b commands user@host" output.log

Content of output.log:
Code:
$ cat output.log 
Script started on Fri Nov 26 11:22:58 2010
sftp> progress
Progress meter enabled
sftp> cd /data/Downloads
sftp> get opera-11.00-1111.i386.linux.tar.bz2
Fetching /data/Downloads/opera-11.00-1111.i386.linux.tar.bz2 to opera-11.00-1111.i386.linux.tar.bz2
/data/Downloads/opera-11.00-1111.i386.linux.t 100%   11MB  10.6MB/s   00:00    
sftp> quit
Hope this helps.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SFTP throwing "End of file" when doing SFTP transfer in perl exceed1 Programming 5 03-06-2010 01:34 PM
Output Redirection - Trying to output to screen and file? helptonewbie Linux - Newbie 7 03-19-2009 07:05 AM
File transfer using SFTP santhoshv Linux - Networking 1 09-18-2008 06:33 AM
implementing a call to output disk space for sftp eugenewg Programming 5 01-10-2005 04:44 AM
the sound gives output when using mic but no output when run a music file medo Debian 0 04-19-2004 07:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration