Capturing output
Hi folks, I am running rsync via a perl script run in a cronjob. Here's the command i'm running my $message = `/usr/bin/rsync --rsh=/usr/local/openssh/bin/ssh -avu $directory $destination`; At the moment when I run the script it writes all output to the screen. I want to be able to write this data to a log file, so that if things don't work, I can find out what's wrong. I've tried writeLog($message); but this misses out some of the stuff that rsync writes to the screen, i.e. the useful stuff actually, like if the file is not found on the machine. Any ideas how I can achieve this? Or is this a perl type question rather than something I can do with rsync...? cheers, Tom -- Tom Freeman Web Developer NISS - EduServ +44 (0)1225 474371 -- To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Re: Capturing output
Tom Freeman wrote: Hi folks, I am running rsync via a perl script run in a cronjob. Here's the command i'm running my $message = `/usr/bin/rsync --rsh=/usr/local/openssh/bin/ssh -avu $directory $destination`; At the moment when I run the script it writes all output to the screen. I want to be able to write this data to a log file, so that if things don't work, I can find out what's wrong. I've tried writeLog($message); but this misses out some of the stuff that rsync writes to the screen, i.e. the useful stuff actually, like if the file is not found on the machine. Any ideas how I can achieve this? Or is this a perl type question rather than something I can do with rsync...? Yes, this is a perl question, not an rsync question. Do perldoc perlop and search for `STRING` (including the backticks). Max. -- To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Re: Capturing output
It may be helpful to capture STDERR with STDOUT. my $message = `/usr/bin/rsync --rsh=/usr/local/openssh/bin/ssh -avu $directory $destination 21`; See: http://perldoc.com/perl5.8.0/pod/perlop.html#%60STRING%60 At 05:47 PM 3/4/2003 +, you wrote: Hi folks, I am running rsync via a perl script run in a cronjob. Here's the command i'm running my $message = `/usr/bin/rsync --rsh=/usr/local/openssh/bin/ssh -avu $directory $destination`; At the moment when I run the script it writes all output to the screen. I want to be able to write this data to a log file, so that if things don't work, I can find out what's wrong. I've tried writeLog($message); but this misses out some of the stuff that rsync writes to the screen, i.e. the useful stuff actually, like if the file is not found on the machine. Any ideas how I can achieve this? Or is this a perl type question rather than something I can do with rsync...? cheers, Tom -- Tom Freeman Web Developer NISS - EduServ +44 (0)1225 474371 -- To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html -- To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Re: Capturing output
Tom Freeman wrote: Hi folks, I am running rsync via a perl script run in a cronjob. my $message = `/usr/bin/rsync --rsh=/usr/local/openssh/bin/ssh -avu $directory $destination`; I want to be able to write this data to a log file, so that if things don't work, I can find out what's wrong. Is this a perl type question rather than something I can do with rsync...? You can do it by shell: `/usr/bin/rsync --youroptions $directory $destination 21 $yourlogfile` This logs stdout and stderr to your log file If you don't like stderr in your output, leave out '21'. If you only like to have stderr, add '2 $yourlogfile' instead of the rest. Patrick -- Engineers motto: cheap, good,fast - choose any two Patrick Strasser past at sbox dot tugraz dot at -- To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html