Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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=categorized question: print w/replies, xml ) Need Help??
Contributed by dswimboy on Jul 26, 2002 at 02:13 UTC
Q&A  > CGI programming


i tried calling <!--#exec cgi="" --> 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/ or wherever. (In apache at least, you can start the path "/" at the document root, or "/cgi-bin/" 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.


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/".


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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

    What's my password?
    Create A New User
    [LanX]: obscure facts: only naturally born monks can become president here!
    [cbeckley]: I have a functioning module I use to spawn sets of commands across multiple servers.
    [cbeckley]: It's nascent, and probably looks like baby Perl to the veterans.
    [cbeckley]: I have several questions about it's future development. But it seems like a lot of code to put in a sopw.

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (12)
    As of 2017-03-24 14:56 GMT
    Find Nodes?
      Voting Booth?
      Should Pluto Get Its Planethood Back?

      Results (304 votes). Check out past polls.