Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Aug 2003 01:10:31 +0200
From:      "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net>
To:        Peter Elsner <peter@servplex.com>
Cc:        FreeBSD-Hackers@FreeBSD.org
Subject:   Re: fetch command sending STDOUT to STDERR
Message-ID:  <200308020110.31823.Danovitsch@Vitsch.net>
In-Reply-To: <5.2.0.9.2.20030801154605.011b2d50@mail.servplex.com>
References:  <5.2.0.9.2.20030801154605.011b2d50@mail.servplex.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 tha=
n 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 successful=
l=20
completion so maybe you could check the return value of the fetch operati=
on=20
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 f=
etch=20
is non-zero)

grtz,
Daan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200308020110.31823.Danovitsch>