[Catalyst] Catalyst::Engine::HTTP and Expect.pm
Frank Wiegand
frank.wiegand at gmail.com
Wed Mar 18 13:06:25 GMT 2009
Hi,
I have problems to get Expect.pm working within the builtin test server.
The following code resides inside a model:
use Expect;
my $exp = Expect->new;
$exp->log_stdout(0);
$exp->spawn('ssh', '-l' => $c->config->{client}{user},
$c->config->{client}{host})
or die "Can't spawn ssh";
$exp->expect( $c->config->{client}{timeout},
[
'Connection closed by remote host',
sub {
die "SSH failed (connection closed)";
},
],
[
'lost connection',
sub {
die "SSH failed (lost connection)";
},
],
[
'Enter passphrase',
sub {
print $exp $self->password . "\r";
exp_continue;
},
],
);
$exp->clear_accum;
# bin/command prints something like »herewego >foobarblubb«
# I want the part after the »>«.
print $exp "bin/command" . "\r";
if ( !$exp->expect($c->config->{client}{timeout}, 'herewego >') ) {
die "failure in remote command";
};
my $wanted = $exp->after;
Using the default test server (Catalyst::Engine::HTTP,
script/myapp_server.pl -r -d), $wanted is empty, but setting
CATALYST_ENGINE='HTTP::Prefork' sets $wanted to the expected value.
If I set $exp->exp_internal(1), then the last log message looks like
spawn id(7): Does `bin/command\r\n'
match:
pattern #1: -ex `herewego >'? No.
Anyone else used Expect.pm and got this behaviour?
I use Catalyst::Engine::HTTP from Catalyst-Runtime-5.8000_06.
Thanks, Frank
More information about the Catalyst
mailing list