Re: Perl Expect help

[email protected] ("Juan Pablo Feria Gomez")
Newsgroups perl.beginners
Message-ID <[email protected]>
Here's a tiny code to get the prompt, hope it helps

	$actualprompt='';
	$rootexpect->send("\n");
	my $shpromvrfy = $rootexpect->expect(750,'#','>','$');
	my $match=$rootexpect->match();
	my @outp = split /\n/, $rootexpect->exp_before();
	$actualprompt= "$outp[$#outp]"."$match";
	print "got $actualprompt\n";





On Fri, May 2, 2008 at 10:33 AM, Ravi Malghan <[email protected]> wrote:
> Hi: I am trying to build a simple perl/expect program which will telnet, run a command and provide me the result of the command in a string or array to process within the script. I have gotten so far as the script telnets, runs the command the prints the result in stdout. I can't seem to figure how to get the result of the command in a string so I can continue processing and do other things within the script.
>
>  my $exp = Expect->spawn($command, @params)
>     or die "Cannot spawn $command: $!\n";
>  $exp->expect($timeout,
>    [qr/login:/ => sub {my $exp = shift;
>                $exp->send("$username\n");
>                exp_continue;
>                } ],
>    [qr/Password: $/ => sub {my $exp = shift;
>                $exp->send("$password\n");
>                exp_continue;
>                } ],
>    [qr/READY$/ => sub {my $exp = shift;
>                $exp->send("select Running from Service WHERE Name = 'CheckForRemedyTickets';\n");
>                exp_continue;
>                } ],
>
>       );
>
>
>
>  TIA
>  Ravi
>
>
>
>       ____________________________________________________________________________________
>  Be a better friend, newshound, and
>  know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
>  --
>  To unsubscribe, e-mail: [email protected]
>  For additional commands, e-mail: [email protected]
>  http://learn.perl.org/
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.