!/bin/bash
#
TCP-ping in bash (not tested)
HOSTNAME="$1"
PORT="$2"
if [ "X$HOSTNAME" == "X" ]; then
echo "Specify a hostname"
exit 1
fi
if [ "X$PORT" == "X" ]; then
PORT="22"
fi
exec 3<>/dev/tcp/$HOSTNAME/$PORT
if [ $? -eq 0 ]; then
echo "Alive."
else
echo "Dead."
fi
exec 3>&-
Recent Comments