title: Handle multiple statements in an Expect script
body: <p>I am new to Expect scripting.</p>
  <p>I wrote an Expect script for ssh in a Linux machine, where I am facing a problem in ssh'ing to different Linux machines. Below I have copied the script.</p>
  <pre><code>!/usr/local/bin/expect
  
  set LinuxMachine [lindex $argv 0]
  
  spawn ssh root@$LinuxMachine
  
  
  expect &quot;root@$LinuxMachine's password:&quot;
  
  send &quot;root123\n&quot;
  
  expect &quot;[root@Client_FC12_172_85 ~]#&quot;
  
  send &quot;ls&quot;
  
  interact
  </code></pre>
  <p>When I supply <code>10.213.172.85</code> from command line the <code>expect</code> in the 4th line, it reads as &quot;<code>root@10.213.172.85's password:</code>&quot; and logs in successfully</p>
  <p>But some Linux will expect</p>
  <pre><code>The authenticity of host '10.213.172.108 (10.213.172.108)' can't be established.
  RSA key fingerprint is da:d0:a0:e1:d8:7a:23:8b:c7:d8:40:8c:b2:b2:9b:95.
  Are you sure you want to continue connecting (yes/no)
  </code></pre>
  <p>In this case the script will not work.</p>
  <p>How can I have two Expect statements in one Expect command?</p>