[ale] Q and REsolved(?): Perl 'Expect' timeout question

Mills John M-NPHW64 Jmills at motorola.com
Mon Oct 4 14:29:31 EDT 2010


ALErs -

First the REsolution(?):
Our network was massively rearranged over the weekend, plus a new version of one of the servers was installed. Running Chris' suggested 'strace' mentioned a '.ssh/known-hosts' problem so I took the Alexandrian approach and recreated that file with fresh entries for my various platforms. That straightened out my net-SSH::Expect scripts.

Thanks.

Now the Question:
Typically my scripts do a simple sequence of (1) execute process on remote, and (2) pick through the response looking for specific text.

No problem doing (1) with 'Expect', but how do I capture each reply to analyze it? I looked over the Expect 'FAQ' and saw references to a session log but I don't see how to make use of it.

TIA for any clarification.

 - Mills 

-----Original Message-----
From: ale-bounces at ale.org on behalf of Jerald Sheets
Sent: Mon 10/4/2010 11:04 AM
To: Atlanta Linux Enthusiasts - Yes! We run Linux!
Subject: Re: [ale] Perl 'Expect' timeout question
 
I'm with Chris on this one.

I've found Net::SSH::Expect to be somewhat buggy and never verbose about what its problems are.  I always have to wrap sessions in my own logic to allow me to figure out what the error is and to be able to log or continue on gracefully.  

If you're looking to just perform a function, spawning ssh inside of Expect is just as secure to use, and removes some of the bugginess.

--j


On Oct 4, 2010, at 10:20 AM, Chris Fowler wrote:

> Use just Expect.
> 
> use Expect;
> use strict;
> 
> my $exp = Expect->spawn('ssh user at host');
> $exp->expect(10, 'password:');
> $exp->send("password\r");
> $exp->expect(5, "]$ ") or die "password authentication failed";
> $exp->send("command\r");
> ....
> 
> $exp->close();
> 
> On Mon, 2010-10-04 at 10:12 -0400, Mills John M-NPHW64 wrote:
>> ALErs -
>> 
>> I wrote a Perl script that uses net-SSH::Expect to connect with a
>> remote target by SSH. I can establish the connection manually without
>> any problem, but my scripts (which had been working) now fail with the
>> message:
>> "SSHAuthenticationError Login timed out" coming from ".../Expect.pm
>> line 813". This line is in the function '_multi_expect($$@)' and the
>> timeout is presumably passed when the function is called.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 4008 bytes
Desc: not available
Url : http://mail.ale.org/pipermail/ale/attachments/20101004/8e64f2b5/attachment-0001.bin 


More information about the Ale mailing list