LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   can scp output be redirected to a file (https://www.linuxquestions.org/questions/linux-newbie-8/can-scp-output-be-redirected-to-a-file-896555/)

dinakumar12 08-10-2011 09:33 AM

can scp output be redirected to a file
 
Hi all,

I have two linux boxes in my network,and they can transfer files through scp without password through ssh key.

My question is,if i run

scp file dinesh@192.168.14.5:/home/dinesh 2&> log

Nothing is registered in log.I want this to be registered because this scp operation is done via cron.so that i can check with the log file if the operation is stopped due to network connectivity or power shut down.

so is it possible to redirect the scp output to a file.

Your suggestion please.

Thanks in advance,
Dinesh.

acid_kewpie 08-10-2011 09:54 AM

write the redirection like this:

Code:

scp file dinesh@192.168.14.5:/home/dinesh 2>&1 > log

catkin 08-10-2011 09:58 AM

Try >log 2>&1

dinakumar12 08-10-2011 10:02 AM

Hi acid and catkin,

Thanks for your replies,but that didn't worked for me.Still nothing is written in the log file.

SL00b 08-10-2011 10:04 AM

Quote:

Originally Posted by catkin (Post 4438787)
Try >log 2>&1

This, plus the -v flag on the scp command, because without the -v flag, you'll get nothing in the log to indicate success.

acid_kewpie 08-10-2011 10:05 AM

this doesn't work in a cron job or on a command line? If it's just a cron, then you'll want to put the full path to the scp binary and run it via bash, not directly.

dinakumar12 08-10-2011 10:08 AM

Hi sloob,

Thanks, i will use scp with -v option,but still i could not get the scp output to the log file.

This is the scp output,when i run

"scp file dinesh@192.168.14.5:/home/dinesh"

file 100% 155 0.2KB/s 00:00


and i want this to be written in the log file,is that possible.

szboardstretcher 08-10-2011 10:09 AM

if you have the choice,.. use 'rsync'

Code:

rsync -varh --progress /from/tmp/ root@192.168.1.1:/to/tmp/ 2>&1 > output.log
More options for rsync than scp.

acid_kewpie 08-10-2011 10:10 AM

if that redirection is being entered correctly, as above, it will be.

dinakumar12 08-10-2011 10:14 AM

Hi acid,

As i mentioned in my previous post,


This is the scp output,when i run "scp file dinesh@192.168.14.5:/home/dinesh"



file 100% 155 0.2KB/s 00:00


and i want this to be written in the log file,is that possible.I have entered the redirection correctly i am sure.But still nothing is written in log file

acid_kewpie 08-10-2011 10:15 AM

yes, if that redirection is being entered correctly, as above, it will be.

dinakumar12 08-11-2011 03:25 AM

Hi,

But thats not working for me,so working on that so please share if you all find any.Thanks all for your replies.

SL00b 08-11-2011 08:16 AM

Quote:

Originally Posted by dinakumar12 (Post 4439395)
Hi,

But thats not working for me,so working on that so please share if you all find any.Thanks all for your replies.

All the answers you need have been provided already, so what exactly is it you're entering that is still not working for you?


All times are GMT -5. The time now is 08:38 AM.