Problem
You want to test a network port, on a remote system – over TCP/IP.
Maybe this is a new setup, or you want confirmation it is working.
Perhaps the firewall rules have just been changed! 🙂
Solution
A nice small bit of Perl code that I’ve used thousands of times!
In fact I’m running it in most of my production environments,
as a check that the a process is not only running – but also responding.
Yep, you could just use telnet – but some systems have that taken off for security.
Additionally it is n’t as easy to program telnet – I know, I know – you can with expect. 🙂
Example
Here is just a one liner, but you can easily incorporate this into a script.
perl -MIO::Socket -e '$socket=IO::Socket::INET->
new(Proto=>tcp,PeerAddr=>$ARGV[0],PeerPort=>$ARGV[1]);
if([email protected]) { print "Failed: [email protected]" } else { print "Succeedn"; }' host port