Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI SSI problems

Status
Not open for further replies.

JoshuaPaschal

Programmer
Nov 15, 2005
11
0
0
US
I am writing in regards to a similar post made on
I have been trying to find out (for the past 12 hours) how to do what you are explaining in the above link.

Right now I have the following:

<!--#set var="body" value="/cgi-bin/search.cgi?${QUERY_STRING}"-->
<!--#include virtual="${body}" -->

With that, I am getting:

HTTP/1.1 404 Object Not Found Server: Microsoft-IIS/5.0 Date: Wed, 16 Nov 2005 05:13:19 GMT X-Powered-By: ASP.NET Connection: close Content-Type: text/html
404 Object Not Found


However with just this:

<!--#include virtual="/cgi-bin/search.cgi" -->

The complete search.cgi file prints across the screen (does not execute).

With this:
<!--#exec cgi="/cgi-bin/search.cgi" -->

The CGI file executes just fine. HOWEVER, I want to be able to pass that CGI variables and the variables are going to be dymanic.

Basically, I am have an SHTML file that passes variables to another SHTML file that in turn calls the CGI file and is supposed to pass the exact same variable to it.

Any suggestions?
 
Feherke,

Here is something odd that i noticed.

When i go to VIEW/SOURCE under IE, i notice that the following line

<!-- #set var="body" value="/cgi-bin/search.cgi?${QUERY_STRING}"-->

can be seen within the SHTML file. However, the other line <!--#include virtual="${body}" --> is not seen.

In other words, it is not processing the first line but, is rather reading it only as a comment. (The second line processes just fine but, it is giving me 404 error because apparently it isn't getting passed the "body" variable properly).
 
That doesn't make a difference. I have tried every possible type of formating.

Anyways, i changed it just for the fun of it.

Here is a snipped of what the original code looks like:

<!-- Begin SSI -->
<!--#set var="body" value="/cgi-bin/search.cgi?${QUERY_STRING}"-->
<!--#include virtual="${body}"-->
<!-- End SSI -->

And the VIEW/SOURCE under IE looks like this:

<!-- Begin SSI -->
<!--#set var="body" value="/cgi-bin/search.cgi?${QUERY_STRING}"-->
HTTP/1.1 404 Object Not Found
Server: Microsoft-IIS/5.0
Date: Wed, 16 Nov 2005 14:42:25 GMT
X-Powered-By: ASP.NET
Connection: close
Content-Type: text/html

<body><h1>404 Object Not Found</h1></body>
<!-- End SSI -->

I THINK THE PROBLEM IS THAT THE #SET VAR ISN'T WORKING. IT DOESN'T SEEM TO WORK REGARLESS OF THE VAR AND VAL VALUES THAT I USE.
 
I noticed that in this thread, within the #SET VAR line, i used VALUE instead of VAL. Either way, in the past i have been using only val and it didn't work.

I added a test line in the code.

Here is the original source:
<!-- Begin SSI -->
<!--#SET VAR="body" val="/cgi-bin/search.cgi?${QUERY_STRING}"-->
<!--#echo var="body" -->
<!--#include virtual="${body}"-->
<!-- End SSI -->

Here is the VIEW/SOURCE under IE:
<!-- Begin SSI -->
<!--#SET VAR="body" val="/cgi-bin/search.cgi?${QUERY_STRING}"-->
<B>Variable 'body' cannot be found</B><BR>

HTTP/1.1 404 Object Not Found
Server: Microsoft-IIS/5.0
Date: Wed, 16 Nov 2005 14:53:56 GMT
X-Powered-By: ASP.NET
Connection: close
Content-Type: text/html

<body><h1>404 Object Not Found</h1></body>
<!-- End SSI -->
 
If #set doesn't work, have you tried one of these?:
Code:
<!--#include virtual="/cgi-bin/search.cgi?${QUERY_STRING}"-->

or

<!--#exec cgi="/cgi-bin/search.cgi?${QUERY_STRING}"-->
Failing that, rewrite your CGI program to extract the calling page's query string - it should be in an environment variable somewhere.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Hi

[tt]value[/tt] is the correct one, at least for Apache. Beside this, would be better to not use uppercase in the code when is not explicitely required.

One time I met a problem with the SSI when there was no space before the closing [tt]-->[/tt]. You could try this too.

I really not want to start a flame, but could you try the same code on other web server ? Perhaps Apache ?

Feherke.
 
Yes, i tried that in the past.

Here is an example:
<!-- Begin SSI -->
<!--#include virtual="/cgi-bin/search.cgi?${QUERY_STRING}"-->
<!-- Middle SSI -->
<!--#exec cgi="/cgi-bin/search.cgi?${QUERY_STRING}"-->
<!-- End SSI -->

The output is
<!-- Begin SSI -->
(output 404 error here) - I have tried entering the exact location of the file (D:\inetpub\044\..etc..etc..) and that doesn't work either.
<!-- Middle SSI -->
here, the url is literally /cgi-bin/search.cgi?${QUERY_STRING}. In other words, its not passing the value of ${QUERY_STRING} but rather passing the exact string "${QUERY_STRING}".
<!-- End SSI -->

I think the best way to tackle this problem is by finding the problem to my original thread. I have been working on this for a long time now and i seem to be the closest using the code in my original thread.
 
I don't have anywhere else to test the code.

I really don't think formating matters (at least on my server) because i have tried all kinds of formating and, the SSI either works or doesn't work regardless of formating.

I would be happy to email someone the code if they want to try it one their server.

You can email me at the following: (strip the spaces)

j o s h u a p a s c h a l (A_T) y a h o o (D_O_T) c o m
 
Here's a way that might do it - put this in your shtml file:
Code:
<!--#exec cgi="/cgi-bin/searchme.cgi" -->
[code]
and create a new searchme.cgi like this:
[code]
#!/usr/bin/perl

# URL of the "real" search script.
$url = "[URL unfurl="true"]http://www.example.com/cgi-bin/search.cgi";[/URL]

# Get the query string (if any) from the calling page
@bits = split /\?/, $ENV{'REQUEST_URI'};
$query = $bits[1];
if ($query) {
   $url .= '?' . $query;
}

# Redirect to the new url
print "Location: $url\n\n";


-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Chris,

Thanks for the code.

Yes, i am sure you code would work flawlessly.

The situation is that i bought a CGI program from a company and there are about 20 CGI files included with it. I have only begun to put together my site and i know that what i want to do will come up a lot.

I guess i might be able to make a generic CGI file that does what you are showing me where i pass to that CGI file the name of the CGI file i want to use...

However, if anyone can think of a way to fix the code I have in the original thread, then I will appreciate it.

Thanks
 
What exactly does the .htaccess file do?

Where do i need to have it?

Could this be a problem?

I have seen several forums where people have had similar problems as i do and many of them point to that file.

Thanks
 
Hi

JoshuaPaschal said:
What exactly does the .htaccess file do?
Why asked ? That is typically Apache and you have IIS.
htaccess.html said:
.htaccess files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top