Reputation: 2610
We create the following simple expect script in order to run the netdata-installer.sh
expect script is:
#!/usr/bin/expect
set timeout 20
send "cd /tmp/netdata\r"
spawn "bash netdata-installer.sh"
expect ">" { send "\r" }
interact
A few words about the netdata-installer.sh
:
In order to run the - netdata-installer.sh
, we need to run it from the working directory - /tmp/netdata
, and this is the reason for me to use in expect the following:
send "cd /tmp/netdata\r"
Then in the expect script I use: (in order to execute ENTER
, by this way we start the netdata installation)
expect ">" { send "\r" }
Until now, it seems things are perfect, but when we run the expect we get:
# ./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
It seems that the expect script does not change the working directory to cd /tmp/netdata
So where am I wrong?
example when we do manual installation:
./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
Reference - https://www.ostechnix.com/netdata-real-time-performance-monitoring-tool-linux/
Remark - the fact that when running the netdata
we need only to give "ENTER" then maybe there are other option to automate this installation ?
Upvotes: 2
Views: 1035
Reputation: 2610
we succeeded to automate the process as the following way ( not by expect )
cd /tmp/netdata
echo -ne '\n' | bash netdata-installer.sh
Upvotes: 3
Reputation: 123440
Instead of trying to build a software robot that can read text and press virtual keys, just ask the program to install non-interactively:
cd /tmp/netdata && ./netdata-installer.sh --dont-wait
Upvotes: 3
Reputation: 137567
You write:
spawn "bash netdata-installer.sh"
That takes bash netdata-installer.sh
as a single value to run, with the space, and then can't find it. Unsurprisingly. You should pass that as several arguments:
spawn bash netdata-installer.sh
Upvotes: 1