Cmdr_Tofu has asked for the wisdom of the Perl Monks concerning the following question:
However, if I do the same thing in a seperate thread, by replacing the call to mysub with the following:#!/usr/local/perl-5.8.0/bin/perl use strict; use threads; use Expect; sub mysub { my $remoteshell; unless ( $remoteshell = Expect -> spawn ("ssh2 192.168.1.1") ) { die "error spawning"; } $remoteshell -> log_stdout(1); unless ( $remoteshell -> expect (120, [ "ssword:" => sub { $remoteshell -> send ("mypasswo +rd\n"); } + ], ) ) { die "no password prompt"; } unless ( $remoteshell -> expect (20,"ro\@charon:") ) { die "no prompt"; } print $remoteshell "touch /tmp/hopo\n"; $remoteshell ->soft_close(); } &mysub;
The program dies instantly with the error:my $h = threads->new(\&mysub); $h->join;
From the processlist I can see that an ssh2 is launched, but the calling program does not even wait the 120 second timeout before dieing with the above error.thread failed to start: no password prompt at ./expect.pl line 21.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Expect.pm and Perl Threading
by robartes (Priest) on Nov 24, 2002 at 14:56 UTC | |
by Cmdr_Tofu (Scribe) on Nov 24, 2002 at 15:32 UTC | |
|
Re: Expect.pm and Perl Threading
by Cmdr_Tofu (Scribe) on Nov 24, 2002 at 16:08 UTC |