Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Testing for port connectivity

by JSchmitz (Canon)
on Sep 04, 2006 at 12:20 UTC ( #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


Comment on Re: Testing for port connectivity
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2014-07-30 09:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (230 votes), past polls