http://qs321.pair.com?node_id=1153544


in reply to Re^11: RFC: Proposed tutorial - simple login script using CGI::Application
in thread RFC: Proposed tutorial - simple login script using CGI::Application

Hi, Thanks for your suggestion and time. I tried the method and Unfortunately it does not working. The browser getting “The server encountered an internal error or misconfiguration and was unable to complete your request” and apache log file show below error.
syntax error at /var/www/cgi-bin/WebApp/libs/libs/MyLib/VPage.pm line +24, near "}" BEGIN not safe after errors--compilation aborted at /var/www/cgi-bin/W +ebApp/libs/libs/MyLib/VPage.pm line 24. Compilation failed in require at /var/www/cgi-bin/WebApp/libs/vpage.pl + line 4. BEGIN failed--compilation aborted at /var/www/cgi-bin/WebApp/libs/vpag +e.pl line 4. Premature end of script headers: vpage.pl
And I’m not sure, what has to define in the “myrunmode.html” file as well.
sub myrunmode: StartRunmode { my $self = shift; my $template = $self->load_tmpl("myrunmode.html"); ### guts of old vpage.cgi go in here my $output="<b> Testing page</br>"; $template->param({ OUPUT => $output; # your output goes in here... }); return $template->output; }
Please let me know if you any suggestion on this, Thanks in advance! Struggling here for last couple of days.

Replies are listed 'Best First'.
Re^13: RFC: Proposed tutorial - simple login script using CGI::Application
by Corion (Patriarch) on Jan 25, 2016 at 10:25 UTC

    I've edited your node and formatted the error message and the Perl code by adding <code>...</code> tags around them. Please use these to properly format your posts.

    You don't show all of the relevant code, but it seems that you have a syntax error somewhere in VPage.pm on line 24 or before that. I suggest using an editor that can show matching braces to show where you forgot to add a brace or parenthesis.

    Finding and fixing syntax errors is a basic skill that is needed for various programming languages. I recommend that you learn it.

    If you cannot make any progress in finding the syntax error in VPage.pm, I suggest removing whole subroutines from it until VPage.pm compiles again. Use perl -wc /var/www/cgi-bin/WebApp/libs/libs/MyLib/VPage.pm to test for compilation errors without a web server. The last subroutine you removed is the one containing the syntax error.

      Thanks for your inputs, I have updated the relevant code .

      perl -wc VPage.pm

      VPage.pm syntax OK
      VPage.pm file and using same Login.pm package MyLib::VPage; use strict; use lib '/var/www/cgi-bin/WebApp/libs'; use base 'MyLib::Login'; sub cgiapp_init { my $self = shift; $self->SUPER::cgiapp_init; $self->authen->protected_runmodes( 'myrunmode', ); } sub myrunmode: StartRunmode { my $self = shift; my $template = $self->load_tmpl("myrunmode.html"); ### guts of old vpage.cgi go in here print "Testing after login success"; # im doing lot of process with +CGI and perl script $template->param({ OUPUT => $output, # your output goes in here... }); return $template->output; } 1;
      vpage.pl - file #!/usr/bin/perl use strict; use lib '/var/www/cgi-bin/WebApp/libs'; use MyLib::VPage; my $webapp = MyLib::VPage->new( PARAMS => { cfg_file => ['simple.ini', 'vpage.ini'], format => 'equal', }, ); $webapp->run();
        You can't use a print statement in a runmode like this (better read the CGI::Application docs more carefully: see the "Important note about run mode methods" section. It says, "never print to stdout"!). Change your "print" statement to this:
        my $output = "Testing after login success.\n";
        Then make sure your myrunmode.html template looks something like this:
        <html> <head> <title>VPage</title> </head> <body> <TMPL_IF OUTPUT><TMPL_VAR OUTPUT></TMPL_IF> </body> </html>

        Note that the OUPUT variable in the template gets populated with the value of the $output variable in the runmode in the $template->param() statement.

        Hi, I need a help , if session got expired how can I redirect to login page