我正在尝试编写一个期望脚本,它将ssh到服务器,发送sudo su,然后检查iptables状态并将输出放在服务器上的日志文件中.下面是脚本.
1 #!/usr/bin/expect
2 exp_internal 1
3 log_user 0
4 set timeout 10
5 set password "******"
6
7 spawn /usr/bin/ssh -l subhasish *.*.*.* -p 10022
8
9 expect {
10 -re "password: " {send "$password\r"}
11 -re "$ " {send "sudo su\r"}
12 -re "[sudo] password for subhasish:" {send "$password\r"}
13 -re "# " {send "service iptables status\r"}
14 }
15 set output $expect_out(buffer)
16 send "exit\r"
17 puts "$output\r\n" >> output.log
Run Code Online (Sandbox Code Playgroud)
但是在调试模式下运行时,我会收到这样的错误;
expect -d testcase
expect version …Run Code Online (Sandbox Code Playgroud) expect ×1