I am new to Perl and HTML . I have written a back end script in Perl using send expect statements, for loops and subroutines. In the Perl script i am logging in to the server and sending some commands and expecting server prompt and finally exit .Now i am trying to bring it to front end using HTML. I am using CGI as a framework to achieve this. This is my part of the code
#!/usr/bin/perl
use Expect;
use Switch;
use warnings;
use 5.008;
use Data::Dumper;
use CGI;
my $q = CGI->new;
my %data;
$data = $q->param('server');
print $q->header;
if($data eq 'null')
{
print '<p> please select a server</p>';
exit;
}
###
$exp->spawn($command, @parameters)
or die "Cannot spawn $command: $!\n";
$exp->send("string\n");
$exp->expect($timeout, @match_patterns);
$exp->expect($timeout,
[ qr/regex1/ => sub { my $exp = shift;
$exp->send("response\n");
exp_continue; } ],
[ "regexp2" , \&callback, @cbparms ],
);
$exp->soft_close();
these are the examples of send expect commands iam using to logging in to server and sending commands. but i am seeing them in the browser how they ll login . but i dont want these to be seen on browser but they should still execute in background
####
print "<html><head><title>Hello World</title></head>\n";
print "<body>\n";
print '<script>checked = false;function checkedAll () {if (checked == false){checked = true}else{checked = false}for (var i = 0; i < document.getElementById("sel").elements.length; i++) {document.getElementById("sel").elements[i].checked = checked;}}</script>';
print '<form action="robostats.pl " method="POST" id="sel">';
print '<input type="checkbox" onClick="checkedAll()">Select All<br />';
foreach my $i (@entire_success) {
print '<input type="checkbox" name="sel" value="';
print $i;
print '">';
print $i;
print '<br />';
}
print '<input type="submit" value="submit">';
print '</form>';
print "</body></html>\n";
so when i am trying to run in the browser those send expect commands, server login prompts are all coming on the browser . I dont want them to be on the browser(they should only come in the console), I only want to capture its output in an array and display the checkboxes of the form on the browser. Please help me o how to achieve this. Thank you