#!/usr/bin/expect
log_user 0 //0不顯示輸出
spawn telnet 10.0.8.250
expect " Login Menu"
sleep 1
expect " Login: "
send "your account\r"
expect " Password: "
send "your passwd\r"
expect "Command>"
send "a\r"
expect "Command>"
send "p\r"
expect "Command>"
send "p\r"
send_user "Complete!!" //送訊息給user
interact
如果要丟變數進expect,可以用 [lindex $argv 0]
相當於shell script中的$1
例如:
send "int gi [lindex $argv 0]\n"
全站熱搜