Skip Menu |

This queue is for tickets about the Net-SSH-Expect CPAN distribution.

Report information
The Basics
Id: 36493
Status: open
Priority: 0/
Queue: Net-SSH-Expect

People
Owner: BNEGRAO [...] cpan.org
Requestors: walkeraj [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.09
Fixed in: (no value)



Subject: ogin() method does not run run_ssh() method in all cases.
I'm using this module to automate the build and setup of virtual machine development boxes for my job. In some instances, it is necessary for me to alter the lilo.conf of a machine and reboot it before build can continue. Basically, I'm doing the following 1) create new Net::SSH::Expect object 2) login 3) do some checks 4) alter lilo.conf 5) reboot 6) wait for machine to become available again 7) login 8) do more work I was testing the ability to re-use a Net::SSH::Expect object called $box, and I noticed that the following code throws an error: ### my $box = Net::SSH::Expect->new ( host => 'hostname', password=> 'xxx', no_terminal => 1, raw_pty => 1, user => 'user' ); $box->login(); $box->close(); $box->login(); my $test = $box->exec("ls -al"); print $test; $box->close(); ### SSHAuthenticationError Login timed out. The input stream currently has the contents bellow: at /usr/local/share/perl/5.8.8/Expect.pm line 828 The following code works, however: ### my $box = Net::SSH::Expect->new ( host => 'hostname', password=> 'xxx', no_terminal => 1, raw_pty => 1, user => 'user' ); $box->login(); $box->close(); $box->run_ssh(); $box->login(); my $test = $box->exec("ls -al"); print $test; $box->close(); ### I guess what's happening is that login() only runs run_ssh() the first time, but not the second time because it thinks the ssh process is still running? Seems as if the solution would be to make the close() method reset the initial state so that a subsequent login() would issue run_ssh() again.
From: walkeraj [...] gmail.com
Attached is a simple diff to fix it. Seems to work for me so far. On Thu Jun 05 16:57:26 2008, walkeraj wrote: Show quoted text
> I'm using this module to automate the build and setup of virtual machine > development boxes for my job. In some instances, it is necessary for me > to alter the lilo.conf of a machine and reboot it before build can
continue. Show quoted text
> > Basically, I'm doing the following > > 1) create new Net::SSH::Expect object > 2) login > 3) do some checks > 4) alter lilo.conf > 5) reboot > 6) wait for machine to become available again > 7) login > 8) do more work > > I was testing the ability to re-use a Net::SSH::Expect object called > $box, and I noticed that the following code throws an error: > > ### > my $box = Net::SSH::Expect->new ( > host => 'hostname', > password=> 'xxx', > no_terminal => 1, > raw_pty => 1, > user => 'user' > ); > > $box->login(); > $box->close(); > > $box->login(); > my $test = $box->exec("ls -al"); > print $test; > $box->close(); > ### > > SSHAuthenticationError Login timed out. The input stream currently has > the contents bellow: at /usr/local/share/perl/5.8.8/Expect.pm line > 828 > > The following code works, however: > > ### > my $box = Net::SSH::Expect->new ( > host => 'hostname', > password=> 'xxx', > no_terminal => 1, > raw_pty => 1, > user => 'user' > ); > > $box->login(); > $box->close(); > > $box->run_ssh(); > $box->login(); > my $test = $box->exec("ls -al"); > print $test; > $box->close(); > ### > > I guess what's happening is that login() only runs run_ssh() the first > time, but not the second time because it thinks the ssh process is still > running? Seems as if the solution would be to make the close() method > reset the initial state so that a subsequent login() would issue > run_ssh() again.
--- Expect.pm 2008-06-05 17:07:22.000000000 -0400 +++ Expect.pm 2008-06-05 17:08:03.000000000 -0400 @@ -473,6 +473,7 @@ my Net::SSH::Expect $self = shift; my $exp = $self->get_expect(); $exp->hard_close(); + undef $self->{expect}; return 1; }
Andrew, this is really a bug and i'll apply your patch this weekend hopefully. Regards, bruno On Thu Jun 05 16:57:26 2008, walkeraj wrote: Show quoted text
> I'm using this module to automate the build and setup of virtual
machine Show quoted text
> development boxes for my job. In some instances, it is necessary for
me Show quoted text
> to alter the lilo.conf of a machine and reboot it before build can
continue. Show quoted text
> > Basically, I'm doing the following > > 1) create new Net::SSH::Expect object > 2) login > 3) do some checks > 4) alter lilo.conf > 5) reboot > 6) wait for machine to become available again > 7) login > 8) do more work > > I was testing the ability to re-use a Net::SSH::Expect object called > $box, and I noticed that the following code throws an error: > > ### > my $box = Net::SSH::Expect->new ( > host => 'hostname', > password=> 'xxx', > no_terminal => 1, > raw_pty => 1, > user => 'user' > ); > > $box->login(); > $box->close(); > > $box->login(); > my $test = $box->exec("ls -al"); > print $test; > $box->close(); > ### > > SSHAuthenticationError Login timed out. The input stream currently has > the contents bellow: at /usr/local/share/perl/5.8.8/Expect.pm line > 828 > > The following code works, however: > > ### > my $box = Net::SSH::Expect->new ( > host => 'hostname', > password=> 'xxx', > no_terminal => 1, > raw_pty => 1, > user => 'user' > ); > > $box->login(); > $box->close(); > > $box->run_ssh(); > $box->login(); > my $test = $box->exec("ls -al"); > print $test; > $box->close(); > ### > > I guess what's happening is that login() only runs run_ssh() the first > time, but not the second time because it thinks the ssh process is
still Show quoted text
> running? Seems as if the solution would be to make the close() method > reset the initial state so that a subsequent login() would issue > run_ssh() again.