Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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
    [ambrus]: ad code examples.
    [ambrus]: I'm not trying to recommend PHP, but I think it has way too bad a name because of its past.
    [ambrus]: This is different from MS Word, which was already a good editor in the pre-unicode days (in word for windows versions 2 and 6, which ran on windows 3 but also on windows 95), only it wasn't trying to solve the task of writing maths papers back then.
    [Discipulus]: ah ok, sounds reasonable; with no fear: Perl all life long
    [ambrus]: Mind you, LaTeX is currently still useful for writing math paper or snippet content without styling in such a way that the
    [ambrus]: formatting conventions of a journal or website can be quickly applied to it, and MS Office and LibreOffice has not quite solved this (although it's better for this than it used to be),
    [ambrus]: which is sort of a drawback compared to the ages of typewritten manuscripts representing content only to which the typesetter applies formatting, but that process required much more manual labor.
    [ambrus]: If you want to typeset a manuscript, you can still do much less work then in the manual typesetting ages and get good formatting.
    [ambrus]: All with only cheap modern computers and software.
    [ambrus]: Something you can have at home and your corner print shop, without a whole printing press's worth of equipment.

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (12)
    As of 2017-09-26 11:12 GMT
    Find Nodes?
      Voting Booth?
      During the recent solar eclipse, I:

      Results (293 votes). Check out past polls.