I have the code like this :
shell script continues ...
....
expect -c"
spawn telnet $ip
expect "login:"
send \"$usrname\r\"
expect "Password:"
send \"$passwd\r\"
expect "*\>"
send \"$cmdstr\r\"
expect "*\>"
send \"exit\r\"
expect eof"
....
shell script continues...
$cmdstr is the command i want to execute on the remote device.
There are several cmds to execute on the remote device,but i have to telnet several times to the device to execute them.
If I can write some shell script inside expect script,then ,it loop to execute each cmd after login in,so it will telnet only once each device to execute all the cmds on it.
Anyone can tell me how to write shell scripts inside expect scripts?
Or,if you get some other methods to telnet only once to execute all cmds.Pls tell me.
Thanks.