title: expect + change directory in expect script
body: <p>We create the following simple expect script in order to run the <code>netdata-installer.sh</code></p>
  
  <p><strong>expect script is:</strong></p>
  
  <pre><code>#!/usr/bin/expect
  
  set timeout 20
  send "cd /tmp/netdata\r"
  spawn "bash netdata-installer.sh"
  
  expect "&gt;" { send "\r" }
  interact
  </code></pre>
  
  <p>A few words about the <code>netdata-installer.sh</code>:</p>
  
  <p>In order to run the - <code>netdata-installer.sh</code> , we need to run it from the working directory - <code>/tmp/netdata</code> , and this is the reason for me to use in expect the following:</p>
  
  <pre><code>send "cd /tmp/netdata\r"
  </code></pre>
  
  <p>Then in the expect script I use: (in order to execute <code>ENTER</code> , by this way we start the netdata installation)</p>
  
  <pre><code>expect "&gt;" { send "\r" }
  </code></pre>
  
  <p>Until now, it seems things are perfect, but when we run the expect we get:</p>
  
  <pre><code># ./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
  </code></pre>
  
  <p>It seems that the expect script does not change the working directory to <code>cd /tmp/netdata</code></p>
  
  <p>So where am I wrong?</p>
  
  <hr>
  
  <p><strong>example when we do manual installation:</strong></p>
  
  <pre><code>./netdata-installer.sh
  
    ^
    |.-.   .-.   .-.   .-.   .  netdata
    |   '-'   '-'   '-'   '-'   real-time performance monitoring, done right!
    +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+---&gt;
  
  
    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 &gt;   &lt;--- in this point we need to ENTER
  </code></pre>
  
  <p>Reference - <a href="https://www.ostechnix.com/netdata-real-time-performance-monitoring-tool-linux/" rel="nofollow noreferrer">https://www.ostechnix.com/netdata-real-time-performance-monitoring-tool-linux/</a></p>
  
  <p><em>Remark - the fact that when running the <code>netdata</code> we need only to give "ENTER" then maybe there  are other option to automate this installation ?</em> </p>