Paulster2 has asked for the wisdom of the Perl Monks concerning the following question:
While trying to port code from our Enterprise server to one of our Blade workstations, I was working through changing directory pointers and so forth. One of the problems I encountered was a problem with Net::Ping, in that I kept getting an error saying “Can’t get tcp protocol by name” or “Can’t get udp protocol by name” depending on which method I was using. I was able ping on the command line to the destination, but still unable to make the code work. The portion of the code was easily tracked down to a part of the Net::Ping module that reads like this:
elsif ($self->{“proto”} eq “tcp”) { $self->{“proto_num”} = (getprotobyname(‘tcp’))[2] || croak(“Can’t get tcp protocol by name”); $self->{“port_num”} = (getservbyname(‘echo’, ‘tcp’))[2] || croak(“Can’t get tcp protocol by name”); $self->{“fh”} = FileHandle->new(); }
I was able to tweak this module a little bit, with pretty good results, as I was able to go back to the original code I was using with minimal porting. It now looks something like this:
elsif ($self->{“proto”} eq “tcp”) { $self->{“proto_num”} = (getprotobyname(‘tcp’))[2]; # || # croak(“Can’t get tcp protocol by name”); $self->{“port_num”} = (getservbyname(‘echo’, ‘tcp’))[2]; # || # croak(“Can’t get tcp protocol by name”); $self->{“fh”} = FileHandle->new(); }
By forcing the module to continue instead of “croak”ing, I was able to let it complete and get the comeback that it needed to succeed. I also changed (earlier in the module) the max timeout value. This is important because the code I am using has to go out and check over 125 workstations. If some of them are dead, the timeout multiplies fast. I was able to use Shell.pm and run it through the command line from within the program, but the time minimum timeout value allowed is one second, so the other day when all of our workstations were down due to an impending power outage, it took forever for that part of the code to run. Using Net::Ping seems to run much faster.
My questions are these to anyone who might be a little bit more experienced than I:
What, if anything, might this break if left this way, and why would this cause a problem in the first place? Since I am using 5.6.0, was this problem fixed with 5.8 (or newer)? Is this a know problem or am I just hosed (no I’m not from Canada)?
Any thoughts would be appreciated.
PS: Sorry for the book.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::Ping Problems (aka I should have posted it here first instead of the PerlMonks Discussion page!)
by Abigail-II (Bishop) on Oct 22, 2003 at 00:17 UTC | |
by Paulster2 (Priest) on Oct 22, 2003 at 22:14 UTC | |
|
Re: Net::Ping Problems
by grinder (Bishop) on Oct 22, 2003 at 06:12 UTC | |
by Paulster2 (Priest) on Oct 22, 2003 at 22:17 UTC |