我做了一个期望代码:
#!/usr/bin/expect -f
spawn ls
expect "*]$*"
send "cd /to/some/path\n"
expect "*]$*"
send "sudo -u root ./program.sh"
期望 "*:*"
发送 "i_am_password\n"
交互
在执行它时,我收到以下错误:
spawn ls
my_pgm.exp abc.sh axyz.zip all.zip test.exp
send: spawn id exp6 not open
while execution
"send "cd /to/some/path\n""
(file "./my_pgm.exp" line 5)
我在 ubuntu 上运行这段代码。请帮忙。