On Tue, Jun 10, 2008 at 04:55:43PM -0700, Noah wrote:
> Hi there,
>
> I am trying to capture the output of a fairly long configuration file
> but it aint working too well. Instead of seeing hundreds of lines I am
> finding only about 3-5 lines are captured. is there a better method?
>
What happens when you set exp_internal? Is expect returning
because you matched something you didn't expect to match?
Austin
> Note how the @showConfiguration variable is getting used.
>
>
> sub grab_config {
> open(OUTPUT, ">$output_filename") or die $!;;
>
> my $target = "${user}\@${ip}";
> my $cmd = "ssh $target";
>
> my $exp = new Expect() || die "Cannot spawn ssh command \n";
>
> $exp->log_file($logfile);
> $exp->raw_pty(0);
> $exp->spawn("$cmd");
>
> #
> # Might get the warning about "Are you sure you want to
> # continue connecting (yes/no)?"
> #
> $exp->expect(2,
> ['yes/no\)\? ',
> sub { my $fh = shift; $fh->send("yes\n");$stat=0;}]);
> $exp->expect($timeout,
> ['assword:',
> sub { my $fh = shift; $fh->send("$pw\n");$stat=0;}],
> [timeout => sub {print STDERR " *** login:Timed out waiting for
> (auth) 'assword:'\n";
> $stat=1;}]
> );
>
> $exp->send("$pw\n");
>
> $prompt = "^$user\@[a-z\.0-9\-]+>";
> $patidx = $exp->expect($timeout, [$prompt]);
> $exp->send("$blah\n");
> $patidx = $exp->expect($timeout, [$prompt]);
>
> $exp->send("$blah\n");
> my @showConfiguration = $exp->expect($timeout, [$prompt]);
>
> $exp->send("quit\n");
> $exp->soft_close();
> print OUTPUT @showConfiguration[3];
> close (OUTPUT);
> }
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Expectperl-discuss mailing list
> Exp...@li...
> https://lists.sourceforge.net/lists/listinfo/expectperl-discuss
>
>
> !DSPAM:484f149820279504617225!
|