fetch command sending STDOUT to STDERR

Daan Vreeken [PA4DAN] Danovitsch at Vitsch.net
Fri Aug 1 16:08:23 PDT 2003


On Friday 01 August 2003 22:54, Peter Elsner wrote:
> For some time now, I've been using FTP to transfer files from one
> server to another.  I recently decided to update my script to use fetch
> instead of FTP.
>
> For some reason, the fetch command seems to be sending STDOUT
> messages to STDERR.
>
> I have a cron job that runs every 15 minutes and fetches some files,
> the output from STDIN is:
> 96 bytes transferred in 0.0 seconds (1.24 MBps)
> 249 bytes transferred in 0.0 seconds (2.70 MBps)
>
> However, I have the STDOUT redirected to a file name in /tmp report.out
> and STDERR redirected to a file name in /tmp report.err
> My script then checks to see if report.err is greater than 0 bytes.
> If it's not, the script exits cleanly (it should), if it is greater than 0
> bytes,
> it sends me an email stating that the file transfer failed, and appends the
> report.err file.
>
> Here is my cron entry:
> */15 * * * * /home/reports/reports.sh >/tmp/reports.out 2>/tmp/reports.err
>
> For the time being, I've redirected STDERR to /dev/null which will stop
> the problem.  However, if the transfer fails, I won't know about it
> either...
>
> Is this normal for fetch?
This won't answer your question, but maybe it will help you.
According to the manual page of "fetch", fetch returns zero on successfull 
completion so maybe you could check the return value of the fetch operation 
something like this :

fetch -o /some/file http://some.url/ 2>/tmp/report.err || do-mail-thing
(the do-mail-thing command will only be executed if the return value of fetch 
is non-zero)

grtz,
Daan


More information about the freebsd-hackers mailing list