title: Weird issue with Net::SSH::Expect in Perl script
body: <p>I am working on putting together a perl script. I have captured it below:</p>
  
  <pre><code>#!/usr/bin/perl
  use Tie::File;
  use Net::SSH::Expect;
  use utf8;
  use warnings;
  use diagnostics;
  
  # Grab password from hidden file
  $pw=`cat .password`;
  chomp $pw;
  
  #Read list of 9200's from hosts.list file into an array
  tie @hosts, 'Tie::File', "hosts.list" or die;
  
  #Loop through hosts, connect via ssh, run commands, and write out log files.
  
  foreach (@hosts) {
  
  #Create ssh session handle
          my $ssh = Net::SSH::Expect-&gt;new (
                  host =&gt; $_,
                  password =&gt; $pw,
                  user =&gt; 'user',
                  raw_pty =&gt; 1
          );
          my $login_output = $ssh-&gt;login();
          if ($login_output !~ /.*sbc.*&gt;/) {
                  die "Login failed. Login output was $login_output";
          }
          $ssh-&gt;send("show sip errors");
          my $line;
          while ( defined ($line = $ssh-&gt;read_line()) ){
                  print $line . "\n";
          }
          $ssh-&gt;close();
  }
  </code></pre>
  
  <p>First, I'm not a programmer, so style is probably very ugly. Sorry about that :) The goal is to run several commands on a remote appliance, capture the results in separate files, which will then be consumed by a 3rd party parsing engine (splunk).</p>
  
  <p>The current implemented functionality is able to log in to remote hosts, run the command, and then print out to stdout. Not quite there, but still shows a good proof of concept.</p>
  
  <p>The script runs fine for the first 3 hosts in the hosts.list file. However as soon as it gets to the fourth host, I receive this exception:</p>
  
  <pre><code>Uncaught exception from user code:
      SSHAuthenticationError Login timed out. The input stream currently has the contents bellow: user@myhost.mydomain's password:  at /System/Library/Perl/Extras/5.12/Expect.pm line 828
   at /Library/Perl/5.12/Net/SSH/Expect.pm line 209
      Net::SSH::Expect::__ANON__('ARRAY(0x7fd718a03008)') called at /System/Library/Perl/Extras/5.12/Expect.pm line 828
      Expect::_multi_expect(1, 'ARRAY(0x7fd7189fbce8)', 'ARRAY(0x7fd7189f7460)') called at /System/Library/Perl/Extras/5.12/Expect.pm line 565
      Expect::expect('Expect=GLOB(0x7fd7189f1878)', 1, 'ARRAY(0x7fd718a01530)', 'ARRAY(0x7fd7189f15a8)', 'ARRAY(0x7fd71890a3d0)', 'ARRAY(0x7fd718a07470)', 'ARRAY(0x7fd7189d8b18)') called at /Library/Perl/5.12/Net/SSH/Expect.pm line 580
      Net::SSH::Expect::_sec_expect('Net::SSH::Expect=HASH(0x7fd718a29828)', 1, 'ARRAY(0x7fd718a01530)', 'ARRAY(0x7fd7189f15a8)', 'ARRAY(0x7fd71890a3d0)', 'ARRAY(0x7fd718a07470)', 'ARRAY(0x7fd7189d8b18)') called at /Library/Perl/5.12/Net/SSH/Expect.pm line 213
      Net::SSH::Expect::login('Net::SSH::Expect=HASH(0x7fd718a29828)') called at ./pcscfFetch.pl line 26
  </code></pre>
  
  <p>Any ideas on what the problem could be? I am able to log in to the host with no issue manually via ssh. The script works fine for our other hosts, it's just this one outlier that I can't seem to figure out. Any advice would be appreciated. Thanks!</p>