The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 03-19-2009
pludi's Avatar
pludi pludi is online now Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,958
nmap isn't quite that useful to test connections. You could install netcat and test the connection using the -z switch, eg
Code:
netcat -z ${MACHINE} 23
if [ $? -eq 0 ]
then
    echo "Telnet accepting connections"
else
    echo "Telnet connections not possible"
fi

Or, if you have bash available and don't want to install anything else you could try replacing the netcat call with
Code:
exec 3>/dev/tcp/${MACHINE}/23

But this is really, really fugly.