in reply to How do I run .pl script from Unix command line, and pass CGI variables to it?

Did you try running it from the command line? If you did, did anything get printed?

Abigail

  • Comment on Re: How do I run .pl script from Unix command line, and pass CGI variables to it?

Replies are listed 'Best First'.
Re: Re: How do I run .pl script from Unix command line, and pass CGI variables to it?
by Lori713 (Pilgrim) on Dec 15, 2003 at 15:50 UTC
    When I run summary.pl from the command line, I get the following message:

    /local/www/htdocs/scripts/campus>nc_rpt_summary.pl Content-Type: text/html; charset=ISO-8859-1

    Software error:

    HTML::Template->new() : Cannot open included file nc_rpt.tmpl : file not found. 
    at /usr/local/lib/perl5.8.0/site_perl/HTML/Template.pm line 1580 HTML::Template::_init_template
    ('HTML::Template=HASH(0x28a914)') called
    at /usr/local/lib/perl5.8.0/site_perl/HTML/Template.pm line 1177 HTML::Template::_init
    ('HTML::Template=HASH(0x28a914)') called
    at /usr/local/lib/perl5.8.0/site_perl/HTML/Template.pm line 1071 HTML::Template::new
    ('HTML::Template','filename','nc_rpt.tmpl',
    'associate','CGI=HASH(0x1800ec)',

    'global_vars',1) called
    at .//nc_rpt_summary.pl line 56

    For help, please send mail to this site's webmaster, giving this error message
    and the time and date of the error.

    Mon Dec 15 09:51:20 2003 nc_rpt_summary.pl: HTML::Template->new() :
    Cannot open included file nc_rpt.tmpl : file not found. at /usr/local/lib/perl5.8.0/site_perl/HTML/Template.pm line 1580
    Mon Dec 15 09:51:20 2003 nc_rpt_summary.pl: HTML::Template::_init_template('HTML::Template=HASH(0x28a914)') called
    at /usr/local/lib/perl5.8.0/site_perl/HTML/Template.pm line 1177
    Mon Dec 15 09:51:20 2003 nc_rpt_summary.pl: HTML::Template::_init('HTML::Template=HASH(0x28a914)') called at /usr/local/lib/perl5.8.0/site_perl/HTML/Template.pm line 1071
    Mon Dec 15 09:51:20 2003 nc_rpt_summary.pl: HTML::Template::new('HTML::Template','filename','nc_rpt.tmpl','associate','CGI=HASH(0x1800ec)','global_vars',1) called at .//nc_rpt_summary.pl line 56

    Lori update: added some breaks so the lines don't run across the page

      I'd say, fix your environment first so that you can run your program from the command line. Now you're getting all kinds of file not found errors unrelated to your original problem.

      Abigail

        Unfortunately, I don't know how to fix my environment (actually, I don't know what's wrong with it). I was hoping by getting the summary.pl to run with some variables passed to it that it would have gotten previously I would get further along in my debugment efforts. The command line error at 56 is referring to a CGI variable that I usually would have passed to it, so it can't find the template because I haven't passed the correct variable info. (Does that make sense?)

        Lori

      Your template paths are relative:

      my $template = HTML::Template->new( filename => 'nc_mainmenu.tmpl', ...

      So either change those to be absolute (/path/to/nc_mainmenu.tmpl) or copy the templates to the directory you're executing the offline script from or check the webserver configuration to see if HTML_TEMPLATE_ROOT is set to something - if so, set your offline environment to have that same variable.

      -derby

        All my files (.pl's and .tmpl's) are in the same directory. Once I pass the CGI variable to it (as Abigail-II pointed me to above), the script runs and generates the HTML based on the template. So I think I have the template paths set up correctly (crossing fingers!). Thanks for your clarification!

        Lori