expect命令问题1

时间:2022-09-25 07:30:26
[root@localhost scripts]# cat exptest.sh
#!/usr/bin/expect
spawn ssh root@127.0.0.1
expect "password: "
send "oracle\r"
sleep
send "ls\r"
#send "ls >/tmp/l3.log\r"
send "echo status:$?\r"
expect -re "status:(\[0-9]+)" { exit $expect_out(,string) }
exit
send "ls\r"
interact

关键字sleep 1,不加的话后面的命令都不会执行,很纳闷