0% found this document useful (0 votes)
4 views

Script

This script checks the connection status of hosts and ports listed in a mailertable file by using telnet. It logs the results along with a timestamp to a log file.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Script

This script checks the connection status of hosts and ports listed in a mailertable file by using telnet. It logs the results along with a timestamp to a log file.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#!

/bin/bash

DATE=`date +%Y-%m-%d`
TIME=`date +%H:%M:%S`
PROG_DIR="$( dirname ${BASH_SOURCE[0]} )"
LOG="$PROG_DIR/log.conPortCheck"

{
echo -e "\n\n## Checking for connection status Starts ##"
echo "----------------------------------------------------"
echo -e "DATE: $DATE\nTIME: $TIME"
echo "----------------------------------------------------"
printf "%-30s | %-5s | Status\n" "Host" "Port"
echo "----------------------------------------------------"

while read host port


do
if telnet -c $host $port </dev/null | grep -q Escape; then
printf "%-30s | %-5s | Connected\n" "$host" "$port"
else
printf "%-30s | %-5s | No Connection\n" "$host" "$port"
fi
done < "$PROG_DIR/mailertable"

echo "----------------------------------------------------"
echo "Finish"
} 2>/dev/null | tee "$LOG"

You might also like