Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Ping from Perl?

Posted by enquirer (enquirer), 1 May 2004
How can I test whether a computer is visible on the network in a Perl program?

Posted by admin (Graham Ellis), 1 May 2004
The Net:ing module is probably the best way to do this - available from the CPAN if you don't already have it loaded.

Here's a module I use to test for web servers running on port 80 ... you can also test for icmp (or udp) rather than tcp visibility - icmp is the "normal" ping but has to be run with admin privelidge.

Code:
use Net::Ping;

package seehost;

# Wrapper around Ping. Wrapper can be amended as need be to tune ping params

sub testhost {
       $p = new Net::Ping("tcp");
       $p->{port_num}=80;
       @result = $p -> ping($_[0],2);
       $result[0];
       }

1;


Built into a program on our inhouse network, this allows us to check all our systems in a few seconds - it does involve a bit of forking (perhaps I should post this as a separate thread?) but we get results like:

Code:
Testing the network (port 80) ...
... ... ...
192.168.200.65 (wind) responded
... ... ...
192.168.200.134 (penguin) responded
...
192.168.200.144 (thursday) responded
192.168.200.145 (friday) responded
192.168.200.160 (mars) responded
...
192.168.200.176 (nan.wellho.co.uk) responded
...
192.168.200.188 (biriani) responded
192.168.200.189 (macdougall) responded
192.168.200.190 (pasanda) responded
192.168.200.193 (tea) responded
...
192.168.200.203 (saturn) responded
...
192.168.200.230 (panther) responded
... ...
Testing completed Trainer's console connected via wireless
Projection laptop connected via wireless
Cable and backup ISDN internet connections both present





This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho