On Nov 4, 6:13 pm, Ted Zlatanov <t...@lifelogs.com> wrote:
> On Tue, 4 Nov 2008 13:54:37 -0800 (PST) Lalo <arn...@gmail.com> wrote:
>
> L> I am using Expect wrapper in perl telnet to machine and do ls -ltra
> L> on remote machine
>
> Have you tried Net::Telnet? It makes the task much, much easier than
> the way you're doing it.
>
> L> my $var = param('VAR');
> L> print "You have chosen : $var.<br><br>\n";
> L> print start_html;
> L> if ($var eq "abc") {
> L> print "\n<br>Your var is : $var: <br>\n";
> L> print "\n<br> Telnet AA.BB.CC.DD 2100: <br><br>\n";
> L> my $exp = new Expect;
> L> my $command = 'telnet AA.BB.CC.DD 2100';
> L> $exp->spawn($command) or die "Cannot spawn $command: $!\n";
> L> print "<br>";
> L> print end_html;
>
> L> print "<br>\n";
>
> L> $exp->send("cd /tmp\n");
> L> $exp->send("ls -ltra > log2.log\n");
>
> L> print start_html;
> L> $exp->send("\x1d\n");
> L> my $tel = $exp->expect(30, 'telnet>');
> L> $exp->send("quit\r");
> L> print end_html;
> L> $exp->interact();
> L> }
>
> L> elsif ($var eq "def") {
>
> L> }
>
> Look at the Template module (AKA Template Toolkit), it will make the
> above much easier by letting you write a simple web page template you
> can fill in with your data. It supports IF-THEN and FOREACH constructs.
>
> I'd suggest doing the work first (in an eval if possible), then
> generating the HTML. Otherwise a problem in the telnet session code
> will break your page.
>
> Ted
Thank you Ted.
I'll take a look at.
To be honest, I haven't looked into it.
Thanks again,
Lalo
|