Pau*_*ner 13 command-line bash scripts expect
我想为我的 django 应用程序做一个自动 collectstatic 脚本。我尝试了各种方法,但没有奏效。我的最后一次尝试是在普通脚本中调用一个期望脚本:
收集静态.sh:
python manage.py collectstatic --settings=app.settings_mark &&
./testscript.sh
Run Code Online (Sandbox Code Playgroud)
测试脚本.sh:
#!/usr/bin/expect -f
spawn testscript.sh
expect "Type 'yes' to continue, or 'no' to cancel:"
send "yes"
Run Code Online (Sandbox Code Playgroud)
但是,该行./testscript.sh永远不会执行,因为collectstatic之前的命令正在等待输入。我怎么能跳过那个?我也试过省略,&&但没有用。
提前致谢 !
为什么不直接发送yes到输入manage.py:
python manage.py collectstatic --settings=app.settings_mark <<<yes &&
./testscript.sh
Run Code Online (Sandbox Code Playgroud)
或者:
echo yes | python manage.py collectstatic --settings=app.settings_mark &&
./testscript.sh
Run Code Online (Sandbox Code Playgroud)