LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 09-19-2005, 03:54 AM   #1
Swakoo
Member
 
Registered: Apr 2005
Distribution: Red Hat / Fedora / CentOS
Posts: 508

Rep: Reputation: 30
SCP - store the stats?


I'm doing some cron job to automate scp of database files to a backup server.
is there anyway i can echo the output by scp to a log file?

Tried >> but doesn't work
 
Old 09-20-2005, 01:12 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Output redirection:
0 = stdin input device such as keyboard
1 = stdout output device usually the console
2 = stderr error message usually displayed at the console

For example: I will run a command which produces an error...
cd /home
ls nofile > test.txt 2>&1
I can view the results with the command: cat test.txt
ls: nofile: No such file or directory

So that command only produced and error which was redirected to test.txt

Now, I run a different command:
ls -al > test.txt 2>&1
I view the results with cat test.txt and see there are no errors and only standard output was redirected to test.txt
total 32
drwxr-xr-x 3 root root 4096 Sep 20 14:12 .
drwxr-xr-x 23 root root 4096 Sep 20 10:05 ..
-rw-r--r-- 1 root root 9168 Sep 20 12:41 file.txt
drwxr-xr-x 20 rctech rctech 4096 Sep 16 16:04 rctech
-rw-r--r-- 1 root root 0 Sep 20 14:12 test.txt
 
Old 09-23-2005, 05:58 AM   #3
Swakoo
Member
 
Registered: Apr 2005
Distribution: Red Hat / Fedora / CentOS
Posts: 508

Original Poster
Rep: Reputation: 30
hi homey thanks for the tip, i will try to incorperate that..
but have some queries

i did a bit of googling ("output redirection" helps!)

1)
ls -al > test.txt 2>&1 is the same as ls -al > test.txt
The only difference is that the latter command will output only standard output (by default?) to the file... where the first outputs standard output and error output.. right?

2) 2>&1 after specifying the output redirection effectively means first redirects the standard output to a textfile, and then redirects the standard error to the same location as the standard output? Am i right?

Ok I try to incorperate with my scp statement but it doesn't work.. am i doing it wrongly..?


Quote:
scp -rp /home/user/db_files/filename.sql.gz user@127.0.0.1:/home/user/userdb_backup/ >> /home/user/cron/logs/dailybackup_log.txt 2>&1
I used >> because I want to concatanate the output to the file... i tried with > also ... but to no avail

but both gave a blank.. am i missing something?
 
Old 09-25-2005, 11:02 PM   #4
Swakoo
Member
 
Registered: Apr 2005
Distribution: Red Hat / Fedora / CentOS
Posts: 508

Original Poster
Rep: Reputation: 30
anyone?
 
Old 10-06-2005, 12:00 AM   #5
Swakoo
Member
 
Registered: Apr 2005
Distribution: Red Hat / Fedora / CentOS
Posts: 508

Original Poster
Rep: Reputation: 30
up.. anyone?
 
Old 10-10-2005, 11:12 PM   #6
Swakoo
Member
 
Registered: Apr 2005
Distribution: Red Hat / Fedora / CentOS
Posts: 508

Original Poster
Rep: Reputation: 30
anyone?

cos I wanna store scp output into a text file..

like every transfer of file, the following will be output on screen

dbname-2005-10-09.sql.gz 100% 13KB 13.1KB/s 00:00

but when i use output redirection, not only the output was not shown on screen (due to output redirection), nothing was stored in the text file. even after I set it chmod 777


so anyone...?
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scp does not work and gives the following error message: scp: FATAL: Executing ssh1 i akay Linux - Networking 16 09-28-2008 11:41 PM
'alsactrl store' doesn't seem to store... endfx Slackware 1 08-20-2004 01:30 AM
DU Stats WhiteWolf Linux - Networking 0 10-01-2003 06:43 PM
reset stats Tinkster LQ Suggestions & Feedback 3 08-07-2003 01:09 PM
Stats reveal too little. yadavankur LQ Suggestions & Feedback 0 12-15-2002 02:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:54 PM.

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