title: Expect within a Bash script
body: <p>I wrote a Bash script with Expect within, to connect to a terminal server and clear lines.</p>
  <p>I am unable to figure out the error I am getting, as in I have given all the braces necessary. I also do not understanding the <code>couldn't read file &quot;line&quot;: no such file or directory</code> error.
  How can I fix this?</p>
  <p>My script:</p>
  <pre class="lang-none prettyprint-override"><code>#!/bin/bash
  VAR=$(expect -c &quot;
  spawn telnet 1.1.1.1
  expect {
         &quot;Password:&quot; { send &quot;password\r&quot; ; exp_continue}
         &quot;Prompt&gt;&quot; { send &quot;en\r&quot; ; exp_continue}
         &quot;Password:&quot; { send &quot;password\r&quot; ; exp_continue}
         &quot;Prompt#&quot; {send &quot;clea line 10\r&quot; ; exp_continue}
         &quot;[confirm]&quot; {send &quot;Y\r&quot; ; exp_continue}
         &quot;Prompt#&quot; {send &quot;clea line 11\r&quot; ; exp_continue}
         &quot;[confirm]&quot; {send &quot;Y\r&quot; ; exp_continue}
         &quot;Prompt#&quot; {send &quot;exit\r&quot; }
      }
  &quot;)
  
  echo $VAR
  </code></pre>
  <p>Its output:</p>
  <pre class="lang-none prettyprint-override"><code>missing close-brace
      while executing
  &quot;expect&quot;
  couldn't read file &quot;line&quot;: no such file or directory
  </code></pre>