On Wednesday 01 March 2006 06:09, SnapafunFrank wrote:
> Resending the following message as the original got hijacked.
>
> Running Mandriva2005LE (kde3.2) and using a Linksys WAG54G Router/Gateway.
>
> Everything usual is working fine for this stand alone system but I need
> to check whether or not a particular port is open.
>
> Pinging a particular address is without problem but a traceroute for the
> same address goes nowhere.
>
> Now I've reached my level of understanding so am seeking advise from
> anyone who would care to point me in the right direction so that I get
> to understand how to use Mandriva ( albeit at konsole ) to check this
> out and if found blocked, how to allow a particular program to access
> the net via a particular port. ( Port is in the 5XXX range and the
> program is OpenMFG_DEMO ).
>
> So I guess that the first thing is to ensure that Mandriva is allowing
> the program though before I double check the Linksys setup.
>
> Any suggestions anyone ?
#!/usr/bin/perl -w
#
# porttest.pl
#
# Perl Script to test connection to ports.
# Used for checking service / server availability
#
# By Jason Lambert
# www.jason-lambert.com
# jason-at-jason-lambert.com
# we want to use sockets
use IO::Socket;
# test that 2 parameters have been passed to script. If not, quit
[EMAIL PROTECTED];
if ($ARGC !=2) {
print "Usage: perl porttest.pl <hostIPaddress> <portnumber> \n";
exit;
}
# assign cmdline values to vars
$remo = $ARGV[0];
$openport = $ARGV[1];
# Test status, if unable to connect, quit with error msg DOWN
unless ($so = IO::Socket::INET->new (Proto => "TCP", PeerAddr => $remo,
PeerPort => $openport))
{
print "DOWN\n";
exit;
}
# Script got to this point, therefore not down, so write UP, and exit
print "UP\n";
close $so;
exit;
Copy the above script to a file called porttest.pl on your system. Make it
executable. Command syntax is ./porttest.pl hostname port. It will either
say DOWN or UP. If it says DOWN, it means there is nothing listening on that
port. If it says UP, it means something is listening on that port.
This is also a very quick and simple way to test server status for things like
web servers and mail servers.
____________________________________________________
Want to buy your Pack or Services from Mandriva?
Go to http://store.mandriva.com
Join the Club : http://www.mandrivaclub.com
____________________________________________________