Sponsored Content
Top Forums Shell Programming and Scripting How to get reason for ping failure using perls Net::Ping->new("icmp");? Post 302820733 by tavanagh on Thursday 13th of June 2013 10:44:05 AM
Old 06-13-2013
How to get reason for ping failure using perls Net::Ping->new("icmp");?

Hi

I am using perl to ping a list of nodes - with script below :

Code:
$p = Net::Ping->new("icmp");
        if ($p->ping($host,1)){
                print "$host is alive.\n";
        }
        else {
                print "$host is unreacheable.\n";
        }
      $p->close();

This works fine however I want the script to tell me the reason why ping fails for the hosts that are not pingable.
Is there any way to print reason why $host is unreacheable using Net::Ping ?
If not is there a better way to ping list of hosts using Perl ?

Thanks
Bernard

Last edited by radoulov; 06-13-2013 at 11:55 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perls "Referance" question

ok im on chap19 (cgi programming) of learning perl 2nd edition. I am just not understanding how the referances to a class work. i understand the following example: @array1=qw( 1 2 3 4); $aref = \@array1; @array2=qw(5 6 7 8); $aref=\@array2; $# of $aref is now 1 print $aref; #... (2 Replies)
Discussion started by: Optimus_P
2 Replies

2. Solaris

limited ping "command" at solaris

Hi... Iam new members at this forum. and I have a little problem with "command ping" what the "command to ping at limited time", for example at linux $ping -c5 10.0.0.62 and the responed as below: 64 bytes from 10.0.0.62: icmp_seq=1 ttl=128 time=0.843 ms 64 bytes from 10.0.0.62: icmp_seq=2... (3 Replies)
Discussion started by: srilinux
3 Replies

3. IP Networking

Ping ICMP

Hi All, How to disable ICMP time stamp request and time stamp reply of a machine? How to test this feature from remote machine? Please reply back Vasanth (2 Replies)
Discussion started by: vasanthan
2 Replies

4. SuSE

VMDB Failure" followed by "Unable to open snapshot file"

keep getting an error when I try to revert to a snapshot: "VMDB Failure" followed by "Unable to open snapshot file" Im using vmware server 1.0.4, host OS is windows xp and guest OS is SLES. Is there anything I can do to recover the snapshot or am I in trouble!?!?! (0 Replies)
Discussion started by: s_linux
0 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Cybersecurity

"authentication failure" then "session opened". Why?

Ssh connections using shared public keys issue “authentication failure” messages, then succeed with “session opened”. I have found a few other threads with similar issue, but no solutions offered. :wall: How can I eliminate the failure messages? Environment: $ uname -a Linux... (0 Replies)
Discussion started by: KennyCason
0 Replies

7. AIX

Ping Failure!!

Hi, Am trying to ping between AIX and FreeBSD7.4/i386 by IPv6 address.. It is unable, I configured all files like /etc/rc.conf at freebsd and /etc/hosts and etc/netsvc.conf and restarted the IPv6 network at AIX.. Please help me where I have missed the procedure.. (1 Reply)
Discussion started by: Priya Amaresh
1 Replies

8. Shell Programming and Scripting

Perl failure with "main::$fn" used only once:" in error logs

Hi all, Can anyone guess why this is happening? I am new to Perl, so please help me to fix this error: - I have a static html file which calls the cgi-perl script. HTML Code: <html> <head> <title> Hey Dude! </title> </head> <body> <form method="POST"... (3 Replies)
Discussion started by: bashily
3 Replies

9. Shell Programming and Scripting

Failure: if grep "$Var" "$line" inside while read line loop

Hi everybody, I am new at Unix/Bourne shell scripting and with my youngest experiences, I will not become very old with it :o My code: #!/bin/sh set -e set -u export IFS= optl="Optl" LOCSTORCLI="/opt/lsi/storcli/storcli" ($LOCSTORCLI /c0 /vall show | grep RAID | cut -d " "... (5 Replies)
Discussion started by: Subsonic66
5 Replies
OCF_PACEMAKER_PING(7)					      Pacemaker Configuration					     OCF_PACEMAKER_PING(7)

NAME
ocf_pacemaker_ping - node connectivity SYNOPSIS
[OCF_RESKEY_pidfile=string] [OCF_RESKEY_dampen=integer] [OCF_RESKEY_name=string] [OCF_RESKEY_multiplier=integer] [OCF_RESKEY_host_list=string] [OCF_RESKEY_attempts=integer] [OCF_RESKEY_timeout=integer] [OCF_RESKEY_options=string] [OCF_RESKEY_failure_score=integer] [OCF_RESKEY_debug=string] ping [start | stop | reload | monitor | meta-data | validate-all] DESCRIPTION
Every time the monitor action is run, this resource agent records (in the CIB) the current number of ping nodes the host can connect to. It is essentially the same as pingd except that it uses the system ping tool to obtain the results. SUPPORTED PARAMETERS
OCF_RESKEY_pidfile = string [/ping-] PID file OCF_RESKEY_dampen = integer [5s] Dampening interval The time to wait (dampening) further changes occur OCF_RESKEY_name = string [pingd] Attribute name The name of the attributes to set. This is the name to be used in the constraints. OCF_RESKEY_multiplier = integer [] Value multiplier The number by which to multiply the number of connected ping nodes by OCF_RESKEY_host_list = string [] Host list The list of ping nodes to count. OCF_RESKEY_attempts = integer [2] no. of ping attempts Number of ping attempts, per host, before declaring it dead OCF_RESKEY_timeout = integer [2] ping timeout in seconds How long, in seconds, to wait before declaring a ping lost OCF_RESKEY_options = string [] Extra Options A catch all for any other options that need to be passed to ping. OCF_RESKEY_failure_score = integer [] failure_score Resource is failed if the score is less than failure_score. Default never fails. OCF_RESKEY_debug = string [false] Verbose logging Enables to use default attrd_updater verbose logging on every call. AUTHOR
Andrew Beekhof <andrew@beekhof.net> Author. Pacemaker Configuration 06/10/2014 OCF_PACEMAKER_PING(7)
All times are GMT -4. The time now is 02:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy