testport.pl


Code Index:


NAME

testport.pl <host> <port>


DESCRIPTION

Test connection on <port> against <host>.


COPYRIGHT

Copyright 2000-2007 Etienne LEMEE <coding AT etilem DOT net>

This piece of code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


#!/usr/bin/perl -w

use strict;

@ARGV > 1 or die << "USAGE";

$0 <host> <port>

test connection on <port> against <host>.
USAGE

sub telport {
    use Net::Telnet;
    my ($h, $p) = @_;
    my $t = new Net::Telnet (Telnetmode => 0);
    $t->open(Host => $h, Port => $p);
    printf "%s => %s", $h, $t->getline;
}

telport @ARGV;