[英]expect: couldn't execute “/usr/bin/zypper patch”: no such file or directory
I wrote an expect script我写了一个期望脚本
vi /foo/force-zypper-patch.exp
cat /foo/force-zypper-patch.exp
#!/usr/bin/expect
set timeout 300
spawn "/usr/bin/zypper patch"
expect "Continue? [y/n/...? shows all options] (y): " { send "y\r" }
interact
but even though I have the zypper with full path, it fails:但即使我有完整路径的 zypper,它也失败了:
SERVER1:~ # ssh SERVER2 "/usr/bin/expect -f /foo/force-zypper-patch.exp"
spawn /usr/bin/zypper patch
couldn't execute "/usr/bin/zypper patch": no such file or directory
while executing
"spawn "/usr/bin/zypper patch""
(file "/foo/force-zypper-patch.exp" line 4)
SERVER1:~ #
SERVER1:~ # ssh SERVER2 "which zypper"
/usr/bin/zypper
SERVER1:~ #
although I can reach my purpose with a "zypper patch -y --with-interactive" but I would be really interested, how to do this in expect!虽然我可以通过“zypper patch -y --with-interactive”达到我的目的,但我真的很感兴趣,如何在期望中做到这一点!
Simply remove the quotes from the spawn
line.只需从spawn
行中删除引号即可。
spawn /usr/bin/zypper patch
Currently, you are trying to execute the command zypper patch
in the /usr/bin
directory, and clearly no such file exists.当前,您尝试在/usr/bin
目录中执行命令zypper patch
,显然不存在此类文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.