Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-18-2008, 04:45 PM
|
#1
|
|
LQ Newbie
Registered: Dec 2005
Posts: 5
Rep:
|
How to redirect the SCP command output to text file.
Hi,
I will first explain my requirement..I'm copying file or dir from other server.
Let say...
i am currently logged in 192.168.1.11 box and copying the dir from 1.10 box.(lets assume this is password less login).
#scp -r 192.168.1.10:/home/test/dir1 /myhome
so the output will be something like this..
dir1 100%|*************************************************| 123KB 12:00:01.. etc...something like this..
I want to redirect the above output to one text file..How to do that..Please guide me...
I tried to redirect using > and | option [result file will be created but empty]
Let me know incase of any questions....
Thanks
Gokul
|
|
|
|
03-18-2008, 04:59 PM
|
#2
|
|
Member
Registered: Jan 2008
Location: Tennessee
Distribution: Arch, Debian, Ubuntu, Puppy
Posts: 39
Rep:
|
I don't know exactly, but maybe this would work?
Code:
#cat `scp -r 192.168.1.10:/home/test/dir1 /myhome` > file.txt
|
|
|
|
03-19-2008, 08:32 AM
|
#3
|
|
LQ Newbie
Registered: Dec 2005
Posts: 5
Original Poster
Rep:
|
Thanks for your reply...
But it didn't work....
|
|
|
|
03-19-2008, 12:24 PM
|
#4
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
Code:
scp -r 192.168.1.10:/home/test/dir1 /myhome 2>&1|tee logfile
Cheers,
Tink
|
|
|
|
03-21-2008, 01:39 AM
|
#5
|
|
LQ Newbie
Registered: Dec 2005
Posts: 5
Original Poster
Rep:
|
I tried above command and i got only empty file...
Thanks
Gokul
|
|
|
|
03-23-2008, 03:17 AM
|
#6
|
|
LQ Newbie
Registered: Dec 2005
Posts: 5
Original Poster
Rep:
|
any other suggestion plz....
|
|
|
|
03-29-2008, 12:41 PM
|
#7
|
|
LQ Newbie
Registered: Dec 2005
Posts: 5
Original Poster
Rep:
|
Quote:
Originally Posted by Tinkster
Code:
scp -r 192.168.1.10:/home/test/dir1 /myhome 2>&1|tee logfile
Cheers,
Tink
|
any suggestion?? i need to find the answer for above question.
need help!
|
|
|
|
03-29-2008, 01:16 PM
|
#8
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
OK. scp shows some weird behaviour here, I wasn't aware of that.
The only way I managed to capture any output from it was using
script (which is quite ugly because of the progress meter).
You'd then need to do some post-processing of the typescript
to get the last part of the output - the one with 100% ...
Cheers,
Tink
|
|
|
|
08-31-2009, 04:04 AM
|
#9
|
|
LQ Newbie
Registered: Aug 2009
Posts: 1
Rep:
|
Worked for me:
Code:
scp -v sourcefile.txt user@targetsystem:/home/test/dir1 >&out.txt
the out.txt file contains all kind of debug info and the last line contains the exit status...
Rgds
Su
|
|
|
|
12-02-2009, 09:59 AM
|
#10
|
|
LQ Newbie
Registered: Dec 2009
Location: Paris, France
Distribution: Debian
Posts: 6
Rep:
|
I'd suggest not to forget the bash mechanism with
scp sourcefile.txt user@targetsystem:/home/test/dir1 && echo "scp done" > out.txt
The only thing you don't have is the file size.
The && effect is that what follows (echo here) will only occur if the first part (scp) ended normally (exit 0). Otherwise nothing happends
In that case scp -q (quiet) can be used.
|
|
|
|
02-22-2012, 02:12 AM
|
#11
|
|
LQ Newbie
Registered: Apr 2009
Location: SA/Botswana
Distribution: SuSE
Posts: 3
Rep:
|
This worked for me
scp -v filetocopy.txt admin@10.20.0.1:/data/ 2> scplog.txt
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:19 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|