anandv has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, could some one help me how to over come this cannot open slave problem from the following code.
use Expect;# http://www.cpan.org: Expect-1.15, IO-Stty-.02, IO-Tty-1.0 +2 use IO::Stty; my $option='0'; my $exp = new Expect(); if($option eq '1') { installXSD(); if (Install is successful) { # some logic here then unInstallXSD(); } } elsif($option eq '2') { unInstallXSD(); } sub installXSD{ $exp->slave->clone_winsize_from(\*STDIN); $exp->spawn("telnet",$host) or die "Can't Spawn a telnet host,".$exp +->exp_error()."\n"; my $expstr = "login: "; $exp->expect(5,$expstr) or die "Can't find login prompt.,".$exp->exp +_error()."\n"; $exp->send_slow(0.1,"$user\r"); $expstr = "Password: ";$exp->expect(5,$expstr) or die "Can't find pa +ssword prompt.,".$exp->exp_error()."\n"; $exp->send_slow(0.1,"$password\r"); $expstr = "\$ "; $exp->expect(10,$expstr)or die "Can't find $ prompt after logging to + host.,".$exp->exp_error()."\n"; # Have some logic here ..... $exp->soft_close(); } sub unInstallXSD{ $exp->slave->clone_winsize_from(\*STDIN); $exp->spawn("telnet",$host) or die "Can't Spawn a telnet host,". +$exp->exp_error()."\n"; my $expstr = "login: "; $exp->expect(5,$expstr) or die "Can't find login prompt.,".$exp->e +xp_error()."\n"; $exp->send_slow(0.1,"$user\r"); $expstr = "Password: "; $exp->expect(5,$expstr) or die "Can't find password prompt.,".$exp +->exp_error()."\n"; $exp->send_slow(0.1,"$password\r"); $expstr = "\$ "; $exp->expect(10,$expstr)or die "Can't find $ prompt after logging +to host.,".$exp->exp_error()."\n"; # Have some logic here ..... $exp->soft_close(); }

20040713 Edit by Corion: Added CODE tags, fixed indentation

Replies are listed 'Best First'.
Re: Cannot open slave error.
by VSarkiss (Monsignor) on Jul 13, 2004 at 22:45 UTC

    It's impossible to determine from what you've written here.

    First, you don't specify the error you're getting. Second, I can't tell what you may have clobbered when you turned the code into pseudo-code. As it stands, nothing will execute because you set $option to 0, and then check for values of 1 and 2. It wouldn't matter anyway, because your two subroutines appear to be identical.

    Take a look at Before You Post ... and How (Not) To Ask A Question for points on asking questions effectively, then post some more info.