View Single Post
Old Jul 12th, 2005, 11:57 AM   #2
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
You can create a function to do the connect and quit for telnet like this
UID="userid"
PWD="passwd"
ip_addr=""
extelnet ()  {
 awk '{ if(NR == 1) {   
        print UI
        print PW
        }
        print $0}
        END{print "quit"}' UI=$UID PW=$PSWD | \
        /usr/bin/telnet  | \
        grep  /^Connected/
 }
          
EMAIL="1.1.1.1  2.2.2.2.2  3.3.3.3"
for ip_addr in $EMAIL
do
    connected=`echo "ls" |  extelent`
    if [ connected -ne "Connected" ]; then
       echo "ip_addr=$ip_addr not connected"
    fi
done

I did not test this code, you need to check it.
jim mcnamara is offline   Reply With Quote