in reply to copy echo message into file

Error messages from /usr/sbin/ping are written to STDERR, so your perl should do something like -
my $result = `ping host 2>&1`;
to capture the error messages into a scalar (and then process it or save it to a file). Or you could do this -
system("ping host >result.txt 2>&1");
from perl to save the results from STDOUT and STDERR of ping into external file 'result.txt'.

Replies are listed 'Best First'.
Re: copy echo message into file
by b10m (Vicar) on Dec 02, 2003 at 10:33 UTC
    Please note that you probably want to add the "-c count" switch, in order to have ping stop at a certain point. So, for example:
    my $result = `ping -c 5 host 2>&1`;
    But in the ping case, you could also have a look at Net::Ping (which I'd prefer over the backticks).
    --
    B10m
Re: Re: copy echo message into file
by Anonymous Monk on Dec 02, 2003 at 05:49 UTC
    hmmm.. thanks mr roger..its working... :)