[ale] Q and REsolved(?): Perl 'Expect' timeout question
Chris Fowler
cfowler at outpostsentinel.com
Mon Oct 4 15:06:46 EDT 2010
On Mon, 2010-10-04 at 14:29 -0400, Mills John M-NPHW64 wrote:
> 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.
{
my $buffer = ""
sub append_buffer {
$buffer .= $_;
}
sub get_buffer { return $buffer; }
sub flush_buffer { $buffer = ""; }
}
$exp->log_file(\&append_buffer);
$exp->send("command\r");
$exp->exepect(30, ']$ ');
my $output = get_buffer();
flush_buffer()
Just an example.
More information about the Ale
mailing list