If Telnet fail abort other command..??

Hi Team,
I my script i telent my node ip and after loging i run some commands...But some time login fail so i want to stop script at that time..

CONFIG_CHNG.sh

printf 'Please Input Node ID : '
read node
node="$node"
 
#exec > node_log_$node.log 2>&1
#set -x
> node_log_$node.log
IP=`cmd_sys Node_$node ======= | grep -i ".111" | awk '{print$3}'`
port=`cmd_sys Node_$node ========== | grep -i ".333" | awk '{print$2}' | cut -c 3- | rev | cut -c 5- | rev`

NEWIP="$IP"

string1="setenv -p PORT"$port"_IPV_GW"
string2="setenv -p PORT"$port"_IPV_IP"
echo ":"
echo ":"
echo ":"
echo "Given node OAMIP:     $NEWIP"
echo "Given node GWIP :     $p"
echo "BH CONCT  PORT  :      $port"
echo ":"
echo ":"
echo ":"

Nodelogin.sh $NEWIP $p $port $string1 $string2                         #Here in this script we login to Node if login fail i need to abort script here

cmd_sys $node ======:======"$port"_VLANID,ENV_VALUE=123
cmd_sys $node =======:======PORT"$port"_IPV_NM,ENV_VALUE=111
cmd_sys $node =======:======E=PORT"$port"_IPVER,ENV_VALUE=4
cmd_sys $node ======:======"$port"_VLANID,ENV_VALUE=123
cmd_sys $node =======:======PORT"$port"_IPV_NM,ENV_VALUE=111
cmd_sys $node =======:======E=PORT"$port"_IPVER,ENV_VALUE=4

Nodelogin.sh

#!/usr/bin/expect
set timeout 2
set ip [lindex $argv 0]
spawn telnet $ip
expect "login:"
send "USER\r"
expect "Password:"
send "pass_123\r"
:
:
:# Here we change some parameter
:
:
exit

Please help me....!!!!!!@@

---------- Post updated at 09:54 AM ---------- Previous update was at 08:01 AM ----------

Please some one ..
Give me some idea!!!!!!

If we don't answer immediately, wait! Nobody here is "on call".

You must alter your expect script to return a value, 0 on success, 1 on error, so that your shell script can tell if anything goes wrong. How to do this depends on your script.

Then you can do

if ! Nodelogin.sh $NEWIP $p $port $string1 $string2
then
        echo "Telnet failed" >&2
        exit 1
fi

Thanks it works...
Sorry for my inpatience