Need to capture multi-line output once command is executed using telnet
<p>I am writing a program to telnet to some switch. Once I am logged in I am executing a command in the switch. Once I execute it, i will get multiple line alarms which I need to capture and later on print it (all of it).</p>

<p>Code Snippet:</p>

<pre><code>def openTelnetSession():

    tn = pexpect.spawn("telnet %s" % (Ipaddress))
    tn.expect("login:") 
    tn.sendline(UID)
    tn.expect("password:")
    tn.sendline(PWD)
    tn.expect("\d+&gt;")
    tn.sendline('required command')
    time.sleep(30) # wait for all the alarms to come
    tn.expect("\d+&gt;")
    print tn.before
</code></pre>

<p>Inside switch:</p>

<pre><code>1&gt; command 

1&gt; alarms 1

1&gt; alarms 2

...

1&gt; alarms n
</code></pre>

<p>I am only able to capture first two alarms, not sure why? Need help
Thanks in advance!</p>
