title: 'if else' statement in Expect script
body: <p>I am trying to create a script which will "send" input as per the output received from executing the previous script.</p>
  
  <pre><code>#!/usr/bin/expect --
  set timeout 60
  
  spawn ssh user@server1
  
  expect "*assword*" { send "password\r"; }
  
  expect "*$*" { send "./jboss.sh status \r"; }
  if [ expect "*running*" ];
          then { send "echo running \r"; }
  else { send "./jboss.sh start \r"; }
  fi
  </code></pre>
  
  <p>I am trying to do something like this, but I am stuck in the <code>if else</code> statement. How can I fix it?</p>