Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: Perl Expect...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 11018 of 11531
Post > Topic >>

Re: Perl Expect help

by jferiago@[EMAIL PROTECTED] (Juan Pablo Feria Gomez) May 6, 2008 at 09:22 PM

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 @[EMAIL PROTECTED]
 = split /\n/, $rootexpect->exp_before();
	$actualprompt= "$outp[$#outp]"."$match";
	print "got $actualprompt\n";





On Fri, May 2, 2008 at 10:33 AM, Ravi Malghan <rmalghan@[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, @[EMAIL PROTECTED]
)
>     or die "Cannot spawn $command: $!\n";
>  $exp->expect($timeout,
>    [qr/login:/ => sub {my $exp = ****ft;
>                $exp->send("$username\n");
>                exp_continue;
>                } ],
>    [qr/Password: $/ => sub {my $exp = ****ft;
>                $exp->send("$password\n");
>                exp_continue;
>                } ],
>    [qr/READY$/ => sub {my $exp = ****ft;
>                $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: beginners-unsubscribe@[EMAIL PROTECTED]
>  For additional commands, e-mail: beginners-help@[EMAIL PROTECTED]
>  http://learn.perl.org/
>
>
>
 




 2 Posts in Topic:
Perl Expect help
rmalghan@[EMAIL PROTECTED  2008-05-02 10:33:25 
Re: Perl Expect help
jferiago@[EMAIL PROTECTED  2008-05-06 21:22:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 19:09:24 CDT 2008.