Operating System - HP-UX
1843266 Members
5301 Online
110214 Solutions
New Discussion

Script to check the connections.

 
SOLVED
Go to solution
Hunki
Super Advisor

Script to check the connections.


I have to check the connections to 4 IP addresses on 10 different ports. Can I get the output in script. Has anybody tried this before.

Thanks .
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor

Re: Script to check the connections.

Here is a very handy Perl script to do this.

Invoke as ping.pl -u for full usage but it's no more difficult than this:

ping.pl -I hostname
STAT=${?}

if [[ ${STAT} -eq 0 ]]
then
echo "OK"
else
echo "failed; status ${STAT}" >&2
fi

If the "echo" service is enabled in /etc/inetd.conf then regular users can use -T (for tcp) or (-U) for udp to attempt to reach the host. -I (ICMP) requires that the script nbe run by root.
If it ain't broke, I can fix that.
Hunki
Super Advisor

Re: Script to check the connections.

Thanks Clay, but I was hoping to telnet to the IP and their respective ports to check the connection to specific ports and I would like to run it as non root.

Thanks !
Ivan Ferreira
Honored Contributor

Re: Script to check the connections.

You may use the nmap command.

http://hpux.connect.org.uk/hppd/hpux/Networking/Admin/nmap-3.93/

With nmap, you can check what ports are open on a remote host.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Script to check the connections.

Okay, here's another Perl script, checktelnet.pl. You will need to download and install the Net::Telnet module from
http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm

and then:

checktelnet.pl -t 15 -P 5555 mickey 2>/dev/null
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "Could not contact host mickey on tcp port 5555; status ${STAT}." >72
fi

Invoke as checktelnet.pl -u for full usage.

If it ain't broke, I can fix that.
Hunki
Super Advisor

Re: Script to check the connections.

Thanks Clay !