From: saravana k. <sar...@gm...> - 2010-09-22 12:13:30
|
Hello All, I want to get the output from expect. I tried with $exp->before(), $exp->after() and $exp->match(), but nothing worked for me. Please find the script below: use strict; use warnings; use Expect; my $output; my $timeout = 200; my $command = 'telnet pvham3-c.ind.hp.com'; my $user='Admin'; #my $host='192.168.47.11'; my $password = 'Admin'; my $exp = Expect->spawn($command) or die "Cannot spawn $command: $!\n"; $exp->expect($timeout, [ qr{MP login: } , sub {$exp->send("$user\n")} ]); $exp->expect($timeout, [ qr{MP password: }, sub {$exp->send("$password\n")} ]); $exp->expect($timeout, [ qr{MP> }, sub {$exp->send("CO\r"); $exp->send("\cEcf"); $exp->send("\r"); $exp->send("map -r\r")} ]); $exp->expect($timeout, [ qr{fs*}, sub {$exp->send("cls\r"); $exp->send("map -r\r")} ]); #$exp->expect($timeout, [ qr{\$ } , sub {$exp->send("ls\n")} ]); #$exp->expect($timeout, [ qr{fs*} , sub {print "got the output: '". $exp->before(). $exp->after(). $exp->match() . "'\n"} ]); $output=$exp->before() . $exp->after(). $exp->match(); $exp->soft_close(); print "The output is ********* $output\n"; >From the above script, i would want to capture the output from "$exp->send("map -r\r")". Appreciate help in advance. --Saravana |