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

How do you pass info to perl through an SSI call on a web page?

by dswimboy (Initiate)
on Jul 26, 2002 at 02:13 UTC ( #185405=perlquestion: print w/replies, xml ) Need Help??

dswimboy has asked for the wisdom of the Perl Monks concerning the following question:

i tried calling <!--#exec cgi="config.pl?var=value" --> from the web page, and i got "an error occurred while processing this directive".

Replies are listed 'Best First'.
Re: How do you pass info to perl through an SSI call on a web page?
by blokhead (Monsignor) on Jul 26, 2002 at 03:06 UTC
    Depending on your Apache setup, you may need to try #include virtual= instead of #exec cgi=. This worked on my server, at least.

    But I think to use this SSI directive, your file must be *.shtml, or else Apache must recognize it as 'server-parsed' .. Somebody correct me if I'm wrong.
Re: How do you pass info to perl through an SSI call on a web page?
by sedhed (Scribe) on Jul 26, 2002 at 17:38 UTC

    In this case, there could be a few things that would cause that error:

    • The script could not be found. Try using the full path to /var/www/cgi-bin/config.pl or wherever. (In apache at least, you can start the path "/" at the document root, or "/cgi-bin/config.pl" in other words.
    • The script was found, but did not return a proper header. This, in turn, can be caused by either by the script not compiling, or of course by the script running just fine, but never actually printing a header. Be sure your program prints a CGI->header() or "Content-Type: text/html\n\n" line.

    Once you get the script to run, you can pass parameters to it by using the #include virtual style of SSI, like so:

    <!--#include virtual="/cgi-bin/somescript.cgi?param1=test&param2=3" -- +>

    blokhead is correct, the server needs to recognize the html file as server-parsed, for which the normal convention is a .shtml extension. Sounds like you're already there though, because the "an error occurred while processing this directive" message embedded in your html page means the server tried to run your script, but couldn't, as stated above.

    Hope this helps.

    Cheers!

Re: How do you pass info to perl through an SSI call on a web page?
by sedhed (Scribe) on Jul 26, 2002 at 17:47 UTC

    Clarification: When using #include virtual, you can't use the full disk path such as /var/www/cgi-bin. You have to use the second option, a path relative to document root, as in "/cgi-bin/config.pl".

    cheers!

Re: How do you pass info to perl through an SSI call on a web page?
by Anonymous Monk on Jul 02, 2004 at 19:55 UTC
    Thank you I was looking to this solution for months. It is worth noting that almost all websites that discuss SSI are wrong or misleading regaurding this. Even worse many reference books on perl have this wrong! Thany you very much.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2022-06-26 04:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (83 votes). Check out past polls.

    Notices?