title: use of if/else statement with pexpect
body: <p>I am trying to write a script in which I would like to access the switch with tacacs credentials with the help of interactive pexpect module. However I would like to use if/else statement and accordingly send different command.</p>
  
  <p>For example:</p>
  
  <p>1) Expecting '<strong>password:</strong>' and sending login password.</p>
  
  <pre><code>abc:PythonScripts$ ssh username@ip_address
  password:
  </code></pre>
  
  <p>2) Expecting "<strong>Are you sure you want to continue connecting (yes/no)?</strong>" and sending command '<strong>yes</strong>'.</p>
  
  <pre><code>abc:PythonScripts$ ssh username@ip_address
  Are you sure you want to continue connecting (yes/no)?
  </code></pre>