expect命令问题1
[root@localhost scripts]# cat exptest.sh #!/usr/bin/expect spawn ssh root@127.0.0.1 expect "password: " send "oracle\r" sleep 1 send "ls\r" #send "ls >/tmp/l3.log\r" send "echo status:$?\r" expect -re "status:(\[0-9]+)" { exit $expect_out(1,string) } exit send "ls\r" interact
关键字sleep 1,不加的话后面的命令都不会执行,很纳闷
笔记