我们创建以下简单的expect脚本以运行netdata-installer.sh
expect脚本是:
#!/usr/bin/expect
set timeout 20
send "cd /tmp/netdata\r"
spawn "bash netdata-installer.sh"
expect ">" { send "\r" }
interact
关于netdata-installer.sh
的几句话
为了运行- netdata-installer.sh
,我们需要从工作目录- /tmp/netdata
运行它,这就是我在expect中使用的原因:
send "cd /tmp/netdata\r"
然后在我使用的expect脚本中使用:(为了执行ENTER
,我们通过这种方式启动netdata安装)
expect ">" { send "\r" }
直到现在,事情似乎是完美的,但是当我们运行expect时,我们得到了:
# ./exp.sh
spawn bash netdata-installer.sh
couldn't execute "bash netdata-installer.sh": no such file or directory
while executing
"spawn "bash netdata-installer.sh""
(file "./exp.sh" line 5)
You have new mail in /var/spool/mail/root
看来expect脚本没有将工作目录更改为cd /tmp/netdata
。
那我哪里错了?
手工安装时的示例:
./netdata-installer.sh
^
|.-. .-. .-. .-. . netdata
| '-' '-' '-' '-' real-time performance monitoring, done right!
+----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->
You are about to build and install netdata to your system.
It will be installed at these locations:
- the daemon at /usr/sbin/netdata
- config files in /etc/netdata
- web files in /usr/share/netdata
- plugins in /usr/libexec/netdata
- cache files in /var/cache/netdata
- db files in /var/lib/netdata
- log files in /var/log/netdata
- pid file at /var/run/netdata.pid
- logrotate file at /etc/logrotate.d/netdata
This installer allows you to change the installation path.
Press Control-C and run the same command with --help for help.
Press ENTER to build and install netdata to your system > <--- in this point we need to ENTER
参考- https://www.ostechnix.com/netdata-real-time-performance-monitoring-tool-linux/
备注--在运行netdata
时,我们只需要给出"ENTER“,那么可能还有其他选项来自动化这个安装吗?
发布于 2019-08-20 17:18:53
与其尝试构建一个能够读取文本并按下虚拟键的软件机器人,只需要求程序非交互地安装:
cd /tmp/netdata && ./netdata-installer.sh --dont-wait
https://stackoverflow.com/questions/57578411
复制相似问题