Skrevet av Emne: Net::Ping::External does not support timeout option on linux  (Lest 3171 ganger)

ATC

  • Gjest
Net::Ping::External does not support timeout option on linux
« på: 06. Oktober 2010, 08:40 am »
  • [applaud]0
  • [smite]0
  • The Perl module Net::Ping::External supports a 'timeout' option but for some reason this is not implemented on the linux platform. A bug report for this was submitted in 2004 and still the auther has not patched the module. Further, it seems impossible to log into the bug tracker to post a solution.



    ATC

    • Gjest
    [Solved] Net::Ping::External does not support timeout option on linux
    « Svar #1 på: 06. Oktober 2010, 08:40 am »
  • [applaud]0
  • [smite]0
  • Edit the relevant file, e.g.

    /usr/lib/perl5/site_perl/5.8.8/Net/Ping/External.pm

    Change this

    sub _ping_linux {
      my %args = @_;
      my $command;
    #for next version
      if (-e '/etc/redhat-release' || -e '/etc/SuSE-release') {
        $command = "ping -c $args{count} -s $args{size} $args{host}";
      } else {
        $command = "ping -c $args{count} $args{host}";
      }
      return _ping_system($command, 0);
    }

    Into this

    sub _ping_linux {
      my %args = @_;
      my $command;
    #for next version
      if (-e '/etc/redhat-release' || -e '/etc/SuSE-release') {
        $command = "ping -c $args{count} -s $args{size} -w $args{timeout} $args{host}";
      } else {
        $command = "ping -c $args{count} $args{host}";
      }
      return _ping_system($command, 0);
    }

    by inserting "-w $args{timeout}"