Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Template Toolkit Root Permission

by romy_mathew (Beadle)
on Mar 24, 2012 at 15:43 UTC ( #961416=perlquestion: print w/ replies, xml ) Need Help??
romy_mathew has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am using Template Toolkit to seperate my html code with perl script, but I face problem when running the perl script on web browser or user other than root showing error "Failed to execute the template toolkit" But when i run as root in the command line I am getting the correct output

Can you suggest me a solution

Below is my script
#!/usr/bin/perl -w use strict; use CGI qw(:standard); use Template; use 5.010; use Data::Dumper; print "Content-Type: text/html\n\n"; #$| = 1; #---------------------------------------------------------- # Define Varriables #---------------------------------------------------------- #..................................................................... +................... my $template = '/var/www/linen_tracking/home.html'; say "hello "; my $hell = "romy"; my $vars = { HELL => $hell, }; #..................................................................... +.................. #..................................................................... +................... # Template Presentation #..................................................................... +................... my $tt = Template->new ({ INCLUDE_PATH => [ '/var/www/e-commerce/template/src/', '/var/www/e-commerce/template/lib/', ], PRE_PROCESS => 'config', PRE_PROCESS => 'variable', ABSOLUTE => 1, RELATIVE => 1, }); $tt->process($template,$vars)|| die "Failed to execute the template $t +t->error() \n";

Comment on Template Toolkit Root Permission
Download Code
Re: Template Toolkit Root Permission
by bms (Monk) on Mar 24, 2012 at 16:10 UTC
    The way that this runs only as root leads me to think that some of the directories you are using don't have read permissions for people other than root, making root the only one who can get any output from the shell. So just add read permissions for all in the directories and files used in your script.

      I could see this script actually is exectuing because it could print hello while exectuing the script but the template part not able to show its output you could see the script executing on

      http://182.18.173.61/cgi-bin/linen_tracking.pl

      I have given complete permission to all the directory

      For E.g if i comment the line #PRE_PROCESS => 'config', #PRE_PROCESS => 'variable', It give me complete output as
      hello <html> <head> </head> <body> <h1>romy</h1> </body> </html>
      else it give me output as only "hello"

        If you check the Template Toolkit manual, you'll notice:

        Multiple templates may be specified as a reference to a list. Each is processed in the order defined.

        my $template = Template->new({ PRE_PROCESS => [ 'config', 'header' ], POST_PROCESS => 'footer', };

        and

        Alternately, multiple template may be specified as a single string, delimited by ':'. This delimiter string can be changed via the DELIMITER option.

        my $template = Template->new({ PRE_PROCESS => 'config:header', POST_PROCESS => 'footer', };

        So, judging by your issue and the way that you have set multiple PRE_PROCESS templates, I think this will fix your problem.

Re: Template Toolkit Root Permission
by mbethke (Hermit) on Mar 24, 2012 at 20:32 UTC
    It may also have to do with write permissions on some temp directory if TT is trying to write precompiled templates somewhere. See the docs on COMPILE_DIR.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://961416]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2014-11-22 21:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (125 votes), past polls