LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-10-2011, 10:33 AM   #1
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Rep: Reputation: 18
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.

Last edited by dinakumar12; 08-10-2011 at 10:34 AM.
 
Old 08-10-2011, 10:54 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
write the redirection like this:

Code:
scp file dinesh@192.168.14.5:/home/dinesh 2>&1 > log
 
Old 08-10-2011, 10:58 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Try >log 2>&1
 
Old 08-10-2011, 11:02 AM   #4
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Original Poster
Rep: Reputation: 18
Hi acid and catkin,

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

Last edited by dinakumar12; 08-10-2011 at 11:05 AM.
 
Old 08-10-2011, 11:04 AM   #5
SL00b
Member
 
Registered: Feb 2011
Location: LA, US
Distribution: SLES
Posts: 375

Rep: Reputation: 112Reputation: 112
Quote:
Originally Posted by catkin View Post
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.
 
1 members found this post helpful.
Old 08-10-2011, 11:05 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
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.
 
Old 08-10-2011, 11:08 AM   #7
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Original Poster
Rep: Reputation: 18
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.

Last edited by dinakumar12; 08-10-2011 at 11:10 AM.
 
Old 08-10-2011, 11:09 AM   #8
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,774
Blog Entries: 1

Rep: Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339
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.
 
Old 08-10-2011, 11:10 AM   #9
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
if that redirection is being entered correctly, as above, it will be.
 
Old 08-10-2011, 11:14 AM   #10
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Original Poster
Rep: Reputation: 18
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

Last edited by dinakumar12; 08-11-2011 at 01:59 AM.
 
Old 08-10-2011, 11:15 AM   #11
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
yes, if that redirection is being entered correctly, as above, it will be.
 
Old 08-11-2011, 04:25 AM   #12
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Original Poster
Rep: Reputation: 18
Hi,

But thats not working for me,so working on that so please share if you all find any.Thanks all for your replies.
 
Old 08-11-2011, 09:16 AM   #13
SL00b
Member
 
Registered: Feb 2011
Location: LA, US
Distribution: SLES
Posts: 375

Rep: Reputation: 112Reputation: 112
Quote:
Originally Posted by dinakumar12 View Post
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to redirect the SCP command output to text file. gokuls Linux - General 10 02-22-2012 03:12 AM
perl script output can't be redirected to a file nasridine Programming 7 02-19-2010 01:13 AM
Apparent File Size Limit for redirected standard output Frank M Salter Slackware 1 08-22-2009 08:53 AM
How to access a redirected output file from within a script adelie Linux - Newbie 5 05-15-2008 05:40 PM
can output of tail be redirected? dsids Linux - Newbie 19 10-16-2006 03:19 AM


All times are GMT -5. The time now is 09:59 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration