Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Testing for port connectivity

by JSchmitz (Canon)
on Sep 04, 2006 at 12:20 UTC ( [id://571070]=note: print w/replies, xml ) Need Help??


in reply to Testing for port connectivity

I think you mean open (IN, "<hostnames.txt" ) || die "Can't open hostnames.txt";

Try something more like this?

#!/usr/bin/perl -w use strict; use IO::Socket::PortState qw(check_ports); my $proto = 'tcp'; my $port = '23'; my $service = 'telnet port'; my $address = '70.114.230.116'; my $porthash{$proto}->{$port}->{'name'} = $section; check_ports( $address, $ping_timeout, \%porthash ); my $open = $porthash{$proto}->{$port}->{'open'}; if ($open) { print "alive\n"; } else { print "dead\n"; }

Cheers -

Jeffery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://571070]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (None)
    As of 2024-04-25 01:07 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found