Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

cgi script embedded in html doesn't like arguments

10:12 pm on Dec 1, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 1, 2003
votes: 0

I've got embedded cgi scripts working. That is, I can take this cgi script called /cgi-bin/helloworld.pl:

print "Content-Type: text/html; charset=ISO-8859-1\n\n";
print "Hello, world";

...and put it in this html file:

<!--#exec cgi="/cgi-bin/helloworld.pl" -->

And the page will properly display "Hello, World".
However, if I add an argument to the script call:

<!--#exec cgi="/cgi-bin/helloworld.pl?myarg=5" -->

I get the dreaded "[an error occurred while processing this directive]"

Are arguments forbidden for some reason?

It's a Linux Apache server.
Thanks for any help.

[edited by: sugarkane at 11:35 pm (utc) on Dec. 1, 2003]

11:38 pm on Dec 1, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 6, 2000
votes: 0

You might have more luck trying

<!--#include virtual="/cgi-bin/helloworld.pl?myarg=5" -->

(although I admit it's quite a while since I've done any SSI ;-) )

3:07 am on Dec 2, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 1, 2003
votes: 0

What? Include?

Sigh... Well, there goes another of my assumptions blown out of the water. I truly thought that "include" meant that it would try to print that file onto the screen, and "exec" meant that it would run the file.

Your suggestion worked, btw. Thanks. Next you're going to tell me there isn't a Santa Claus, right?

8:36 pm on Dec 3, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:July 19, 2003
votes: 0

No, you used to be right, and "include" used to be just to include the contents of a file. But "include virtual" is a newer (relatively -- only a few years old) thing that calls the included file through the web server (or calls it as though it were calling it through the web server). For CGI scripts, this has the effect of executing the script, but I think you can do it for html and other files as well.

Lots of places have taken to disabling all forms of "exec" in SSI and using "include virtual" instead, which may be why you were having the problem.



[edited by: jatar_k at 10:05 pm (utc) on Dec. 3, 2003]


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members