Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Do you know where your variables are?
 
PerlMonks  

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

( #185405=categorized question: print w/ replies, xml ) Need Help??
Contributed by dswimboy on Jul 26, 2002 at 02:13 UTC
Q&A  > CGI programming


Description:

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

Answer: How do you pass info to perl through an SSI call on a web page?
contributed by blokhead

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.

Answer: How do you pass info to perl through an SSI call on a web page?
contributed by sedhed

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!

Answer: How do you pass info to perl through an SSI call on a web page?
contributed by sedhed

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!

Answer: How do you pass info to perl through an SSI call on a web page?
contributed by Anonymous Monk

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.

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (4)
    As of 2014-04-19 21:15 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (483 votes), past polls