interface between perl script and HTML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sai prudvi
    New Member
    • Mar 2014
    • 2

    #1

    interface between perl script and HTML

    hi
    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

    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;
    
    }
    
    
    ### here are the send expect commands of logging in to server and sending commands ####
    
    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
    Last edited by Rabbit; Mar 7 '14, 04:07 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • sai prudvi
    New Member
    • Mar 2014
    • 2

    #2
    use " $exp->log_user(0); " before the first expect statement . it worked for me .....

    Comment

    Working...