Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

ping with perl

by varalaxmibbnl (Acolyte)
on Sep 06, 2013 at 13:50 UTC ( [id://1052715]=perlquestion: print w/replies, xml ) Need Help??

varalaxmibbnl has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: ping with perl
by choroba (Cardinal) on Sep 06, 2013 at 13:56 UTC
    Posting in full caps is similar to shouting in spoken dialogs. Please, avoid that.

    system does not return the output of the command, it returns its exit status. Use backquotes or qx{} to capture the output, or read perlipc for more advanced solutions.

    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: ping with perl
by Corion (Patriarch) on Sep 06, 2013 at 13:58 UTC

    In addition to the concrete points mentioned by the others, you may want to investigate Net::Ping. Somewhat more advanced is AnyEvent::Ping, which can ping multiple adresses in parallel, but its usage is not as straightforward for somebody not yet familiar with AnyEvent. Also, AnyEvent::FastPing, which even uses its own OS thread to send and receive the packets in the background, and which also has rate limiting.

Re: ping with perl
by hdb (Monsignor) on Sep 06, 2013 at 13:55 UTC

    If you remove OUTFILE from the print statements, do you get the desired output?

Re: ping with perl
by Laurent_R (Canon) on Sep 06, 2013 at 17:54 UTC

    The system function is not returning the output of the called OS command, but the exit status of the forked child. If you want to retrieve the output, you need to use the backticks, although I am not sure what the result will be with a ping command.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1052715]
Approved by hdb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-24 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found