Welcome to WebmasterWorld Guest from 23.22.46.195

Forum Moderators: coopster & jatar k & phranque

cgi script embedded in html doesn't like arguments

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

10+ Year Member



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

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

...and put it in this html file:

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

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

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

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)

WebmasterWorld Senior Member 10+ Year Member



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)

10+ Year Member



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)

10+ Year Member



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.

:-)

JK

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

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month