我想在windows中编写一个shell程序,它运行另一个shell脚本,并期望从Git bash终端输入密码提示。这就是我到目前为止所知道的:
#!/bin/sh
# \
exec tclsh "$0" ${1+"$@"}
package require Expect
spawn sampleScript.sh
expect "Password:"
send "pass123"sampleScript.sh代码:
echo 'Hello, world.' >foo.txt我的程序输出以下内容:
'The operation completed successfully. while executing "spawn sampleScript.sh"
(file "compare.tcl" line 6)'但是,在我的脚本所在的本地文件夹中没有创建foo.txt。你能帮上忙吗?
发布于 2020-10-13 23:27:53
expect程序的关键是让衍生的程序优雅地退出。按照目前的情况,在expect脚本发送密码后,它会立即退出,这会过早地杀死生成的程序。
expect eof
interact
读取How to create a Minimal, Reproducible Example --更新后的代码不会重现您看到的错误
send "password\r"expect eof到Tcl脚本?否则,您可能会在sampleScript.sh 有机会创建输出file之前终止它
https://stackoverflow.com/questions/64320982
复制相似问题