我想为我的 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之前的命令正在等待输入。我怎么能跳过那个?我也试过省略,&&但没有用。
提前致谢 !
我发现“unbuffer”命令非常重要和有用,因为我正在运行 python 代码,而且我认为我不能在任何地方放置与 fflush() 等效的东西。
我以前用的很好: unbuffer python foo.py | tee filename.log
几个月前,我不确定我是否允许我的 Ubuntu 16.04 自动更新某些软件,但它停止工作。
$ unbuffer
can't find package Expect
while executing
"package require Expect"
(file "/usr/bin/unbuffer" line 6)
Run Code Online (Sandbox Code Playgroud)
我尝试编辑一些文件并更改Expect为小写,expect但没有用。
我尝试(几个月前)使用 apt-get 工具卸载并重新安装 Expect,但无济于事。我很惊讶我不能谷歌这个并发现其他人抱怨它不起作用。
我刚刚在朋友的 18.04 Ubuntu 上尝试过。他从未使用过它,他用 apt-get 下载了它并得到了同样的失败信息。任何帮助表示赞赏。
感谢@pynexj 对 cat /usr/bin/unbuffer 的建议:
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
exec tclsh8.6 "$0" ${1+"$@"}
package require expect
# -*- tcl -*-
# …Run Code Online (Sandbox Code Playgroud) 我希望有比我更聪明的人可以帮助我解决这个问题。看来我的 apt 数据库中有些东西搞砸了。
我正在运行 Ubuntu 16.04.2 LTS。我已经从 ossec.wazuh.com 下载了 ossec-hids_2.8.3-4xenial_amd64.deb,当我尝试安装它时,我得到:
# dpkg -i ossec-hids_2.8.3-4xenial_amd64.deb
Selecting previously unselected package ossec-hids.
(Reading database ... 162578 files and directories currently installed.)
Preparing to unpack ossec-hids_2.8.3-4xenial_amd64.deb ...
Unpacking ossec-hids (2.8.3-4xenial) ...
dpkg: dependency problems prevent configuration of ossec-hids:
ossec-hids depends on expect; however:
Package expect is not installed.
dpkg: error processing package ossec-hids (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
ossec-hids
Run Code Online (Sandbox Code Playgroud)
当我去安装expect时,我得到:
# apt-get install expect
Reading package lists... Done …Run Code Online (Sandbox Code Playgroud) 我想让shell脚本启动sudo apt-get update,自动插入密码sudo并自动按回车键。
我试过了:
#!/bin/bash
sudo apt-get update
expect "[sudo] password for username: "
send "password"
Run Code Online (Sandbox Code Playgroud) 我想对简单的 .sh 文件使用 autoexpect,但终端显示此错误:
can't find package Expect
while executing
"package require Expect"
(file "/usr/bin/autoexpect" line 6)
Run Code Online (Sandbox Code Playgroud)
我的终端命令是:
autoexpect shell.sh
Run Code Online (Sandbox Code Playgroud)
我删除了expect并再次安装它,但与过去没有区别!
谁能帮我?
这是 的输出dpkg -l | grep tcl; which tclsh; which tclsh8.6; dpkg -S Expect; echo $PATH。Anaconda 与预期相矛盾吗?
我有一个登录到我的 Beaglebone 的期望脚本:
#!/usr/bin/expect -f
spawn ssh debian@192.168.7.2
expect "debian@192.168.7.2's password:"
send "temppwd\r"
interact &&
mkdir emma &&
cd emma
Run Code Online (Sandbox Code Playgroud)
这有效并且它登录到 debian 帐户。但是,它会在interact其他两个命令未执行后停止。我该怎么做才能做到这一点?
编辑
好的,谢谢 andy256 我想这interact是错误的,但是,我明白了
执行时无效的命令名称“mkdir”
如何将期望脚本与普通 shell 脚本结合起来?
提前致谢 !
expect ×6
bash ×4
command-line ×3
scripts ×3
apt ×2
16.04 ×1
18.04 ×1
beagleboard ×1
dependencies ×1
dpkg ×1