LaPole, Chris wrote:

> Howdy.  I have written a script to ping a list of Computer Names and remove
> any from that list that reply.  My problem is </sarcasm on> a few years ago
> someone brilliant </sarcasm off> decided to set the computer names to a
> numeric string (e.g. 0070123) and we still have several of those in
> existence.  The problem is that when trying to do a ping, the value passed
> is considered an IP if it begins with a number.  Does anyone know of a way
> to force a ping command to believe a numeric value is a computer name and
> not an IP address?
> 
> 
> 
> More background info for those who are interested, but not meant to take up
> your time.  I am in a completely Windows environment.  The script I have
> written takes a list of targets from a text file whose values are separated
> by \n.  The list is sucked in and stored in an array, then each value is
> pinged using the Net::Ping module setup as
> 
> my $tellit = Net::Ping->new('icmp',2)
> 
> and whenever a computer name/IP does not respond it is written to a new
> array.  The content of the new array then overwrites the contents of the
> original file.  The whole point of this is to see what machines have
> actually been alive on the network over some period of time.  I will be
> setting this to run as a schedule under NT/2000.  I am still very new to
> Perl, and I am sure there would be an easy way to do this, but it seems to
> work minus the problem above.


You could try using gethostbyname first and passing the dotted addr to ping.


use Socket;
my @addr = gethostbyname ('0070123');
print "@addr\n";
print inet_ntoa ($addr[4]), "\n";

__END__

-- 
   ,-/-  __      _  _         $Bill Luebkert   ICQ=162126130
  (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to