Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Howto include Perl Script into CGI script

by monkfan (Curate)
on May 17, 2006 at 09:37 UTC ( [id://549975]=note: print w/replies, xml ) Need Help??


in reply to Re: Howto include Perl Script into CGI script
in thread Howto include Perl Script into CGI script

(You could also run the Perl script by using back-quotes, shell-script style.)
Hi BerntB,

Thanks for your answer. Can you be a bit specific? Example?
Here is what I have at the moment:
sub print_results { my @top = param('toppings'); print b('Customer name: '), param('customer'), br, "You ordered ", param('no_unit'), ' unit of ', param('cone'), ' cone.'; print br; my $value = `perl compute_price.pl -type param('cone') -unit param +('no_unit')`; # Still doesn't show the value. What did I do wrong?? print 'Total price is', $value; }
But it doesn't show the price as you try see from the link I have above. Is there anything I did wrong?
It seem to me CGI script has different property with Perl script. Maybe backquote is not for it?

Regards,
Edward

Replies are listed 'Best First'.
Re^3: Howto include Perl Script into CGI script
by BerntB (Deacon) on May 17, 2006 at 09:45 UTC
    The "param('no_unit')" parts (inside the backquotes) are evaluated as shell script. Set them to variables and have the variables inside the "`".

    Update: Please note the dangers of "injecting" stuff like shell commands into your backquotes-eval if you use data that comes from the CGI! Use taint and/or the system() call with multiple parameters. (I.e. do system("perl", $param1, $param2);)

      Use taint and/or the system() call with multiple parameters.
      I learnt so much from your replies.
      How do you actually do the "tainting", in my OP above?

      Regards,
      Edward
        #!/usr/bin/perl -wT
        Turns on taint checking.

        Have a look at Ovid's CGI Course, lesson 3, Basic CGI Security for a discussion on why and how to use it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://549975]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-24 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found