[lug] Perl 101

John Karns jkarns at csd.net
Thu Apr 18 15:24:20 MDT 2002


I'm just beginning to dig into Perl a bit to learn enough to write
implement some rudimentary scripts.  For starters, using O'Reilly's
Perl Bookshelf CD as a reference and learning source, I have:

#---------------------- cut --------------------------
#!/usr/bin/perl

use Net::Ping;

$hostname = "192.168.1.108";
$timeout = 50;

if (pingecho($hostname, $timeout)) {
	print "host is alive\n";
	}
exit ;

#---------------------- cut --------------------------

which is an example from the CD and fails, although I can see the lights
flash on the destination machine's NIC when I run the script.  Command
line pings also work fine.  The text from the CD says that there is no
guarantee that the call will succeed but as I said, it does seem to doing
the probe.  I've tried it without the optional timeout parm as well with
identical results.  So I'm wondering if it's a configuration issue or
something else.  The idea is to have a script on my laptop that will
detect which LAN it's connected to, and do various tasks based on that.

Is there an alternative method that might be preferred to my approach?
Any suggestions greatly appreciated!

----------------------------------------------------------------
John Karns                                        jkarns at csd.net




More information about the LUG mailing list