Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用spawn执行bash脚本_Bash_Expect_Spawn - Fatal编程技术网

无法使用spawn执行bash脚本

无法使用spawn执行bash脚本,bash,expect,spawn,Bash,Expect,Spawn,我有一个脚本包含以下内容: #!/usr/bin/expect spawn /user/home/scripts/shutdown.sh expect "password\r" 我正在尝试执行脚本-->。/scriptname 但是shutdown.sh脚本不会执行。关于这方面有什么线索吗?你应该抓住像这样的繁殖错误 if [ catch "spawn /user/home/scripts/shutdown.sh" reason ] { puts "Could not

我有一个脚本包含以下内容:

   #!/usr/bin/expect
   spawn /user/home/scripts/shutdown.sh
   expect "password\r"
我正在尝试执行脚本-->。/scriptname


但是shutdown.sh脚本不会执行。关于这方面有什么线索吗?

你应该抓住像这样的繁殖错误

if [ catch "spawn /user/home/scripts/shutdown.sh" reason ] {
   puts "Could not spawn shutdown.sh $reason"
}

。。。通过这种方式,您可以看到在生成脚本时确实存在任何错误。

为什么要求
expect
运行脚本?您可以直接运行
/user/home/scripts/shutdown.sh
。您确定shutdown.sh的路径吗?运行expect脚本时会收到什么错误消息?您如何知道脚本确实运行了?如果[catch“spawn/user/home/scripts/shutdown.sh”reason]{puts“未能生成shutdown.sh$reason”},请尝试使用
捕捉任何生成错误
我正在使用Expect,因为我需要提供运行脚本的密码。