I enclosed a script ("portlook.sh") with a prior posting, that I have used off and on for several years, to verify names/ips and ports.

In re-testing (er, after sending it to Lan), I discovered a couple anomolies

1. the netcat -z switch used to be needed when you didn't want to send anything, even an empty line -- ie you just wanted to see if a port connect was possible. The nc -z was evidently interpreted as send zilch, then receive.

It (the -z) seems no longer needed when just doing a scan, and in fact seems to interfere with looking for a port. so I have modified my script to remove the "z"

2. The current netcat version distributed with FC5 has a bug in the wait (-w) option, which makes the script annoyingly slow in reporting negative results.

I found that FC6 has a src package with a "connect_with_timeout.patch", so I tried compiling and running that and it seems to work fine. I got my src at:

ftp://chuck.ucs.indiana.edu/pub/array2/linux/fedora/linux/core/development/source/SRPMS/nc-1.84-8.fc6.src.rpm

my current version of portlook.sh with the -z removed looks like:

=*=*=
#!/bin/sh
#TODO: add -q (quiet) switch,
# maybe -v (verbose) instead, or, in addition
# Notes:
# -z (send-nothing switch seemingly no loinger needed)
# -wN broken is v1.84-3 from FC5 -- use 1.84-8 from FC6

function usage {
    PGM=${0##*/}
    cat <<END_USAGE
Usage: $PGM url [port]
 a url is required; port defaults to 80 (http)
 port may also be a service name such as http, ftp
 examples:
   $PGM yahoo.com
   $PGM www.yahoo.com 80
END_USAGE
    exit 91
}

which nc &>/dev/null || { echo "required nc program seems missing"; exit 92; }
[ -n "$1" ] || usage
URL=$1
PORT=${2:-"80"}
echo checking for connectivity to "$URL" port "$PORT" ..
nc -w3 "$URL" "$PORT"
RC=$?
[ $RC -eq 0 ] && echo YES || echo nope
exit $RC
=*=*=

Regards,
..jim


--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to