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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script problem on IIS 6

Status
Not open for further replies.

JerryBarrett

Technical User
Jan 18, 2004
76
GB
<!--#if expr = "${SERVER_SOFTWARE} = /Apache/" -->
<!--#exec cgi="./cgi-bin/testtags.pl"-->
<!--#else -->
<!--#exec cgi="/cgi-bin/testtags.pl"-->
<!--#endif -->

Wullie kindly suggested this in my HTML to load up a set of tags according to the url of the site - cool it worked a treat until IIS6 (Just upgraded due to a disk crash - now gone RAID1 with Win2K3)

Now it executes twice ignoring the if-then-else and of course creating an error when it cant find the file in the first path - becuase its a Unix path, the second is the one I would expect to be run on Windows IIS and in fact it does run the script quite well.

So why does it ignore the if-then-else and try and exec both commands? - This is so frustrating to test.

Regards
Jerry
 
<!--#if expr = "${SERVER_SOFTWARE} = /Apache/" -->
<!--#exec cgi="./cgi-bin/testtags.pl"-->
<!--#else -->
<!--#exec cgi="/cgi-bin/testtags.pl"-->
<!--#endif -->

The if,else,endif tags are just comments, is this an SSI?

You're using IIS6 not apache so change the whole block to simply
Code:
<!--#exec cgi="/cgi-bin/testtags.pl"-->

PS I've not seen ${SERVER_SOFTWARE} as a variable, should that be $ENV{SERVER_SOFTWARE}

HTH
--Paul
 
Paul Hi
I use both Apache and Windows IIS and this code bit did (last week) work a treat on the IIS machine - it still works on the Apache servers.

The testtags.pl is a common set of tag defs for the headers of about 25 sites - each tag set is different depending on the site URL but the web site content HTML is the same - this allows me to update the website content or the tag content on-mass..

the only problem I had was that the path defs for each type of server were slightly different as the example shows.

The if-then-else is a valid SSI command structure, its just IIS6 - ActivePerl 5.8 seems not to be processing it.

and running both exec cgi commands - of course one is in error (Unix) as the path to the perls cript is incorrect when run on IIS6

example - Windows IIS6 with error 3 plainly visible at the top of the page - this is where IIS6 is trying to run the script from the unix/apache path.

and - Apache server

Both are identical websites with identical CGI/perl scripts and HTML but the metatags are different (check browser title)

HTH clarify my problem
Jerry
 
Have you set IIS to recognize .PL extensions? As I recall, this is not a default with IIS and has to be configured for it.

There's always a better way. The fun is trying to find it!
 
I have setup up IIS6 to deal with .pl .plx and .cgi and .shtml and .shtm - I have even upgraded to ActivePerl 5.8.3 (win2K3 support and enable Perl extns)

Perls runs - Thats not the problem... in deed if you look at the websites I provided examples of you will see the Browser title change for each - this is the perl scripts actually running at startup and putting seperate HTML tags into the pages.

The problem is why does it ignore the if-then-else structure?

Jerry
 
It would appear that PaulTEG had it right:

Code:
<!--#if expr = "${SERVER_SOFTWARE} = /Apache/" -->
    <!--#exec cgi="./cgi-bin/testtags.pl"-->
<!--#else -->
    <!--#exec cgi="/cgi-bin/testtags.pl"-->
<!--#endif -->

should be this:

Code:
#if expr = "${SERVER_SOFTWARE} = /Apache/"
    #exec cgi="./cgi-bin/testtags.pl"
#else 
    #exec cgi="/cgi-bin/testtags.pl"
#endif

Looking at the source code, the if-else is clearly commented out and the browser is ignoring it.

There's always a better way. The fun is trying to find it!
 
Ummmm - I don't understand - maybe I'm not bing very clear

<!--#if expr = "${SERVER_SOFTWARE} = /Apache/" -->
<!--#exec cgi="./cgi-bin/testtags.pl"-->
<!--#else -->
<!--#exec cgi="/cgi-bin/testtags.pl"-->
<!--#endif -->

is in a HTML file not a .pl file.

Bareing in mind I haven't changed this code fragment and its in 25 websites HTML files over 250 pages of HTML which was working and those websites on an Apache server still are working as expected - why has this failed in IIS6?

Oh I did try your idea in a test HTML file and it doesn't like it much.


Heres the source to this page

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<!--#if expr = "${SERVER_SOFTWARE} = /Apache/" -->
<!--#exec cgi="./cgi-bin/testtags.pl"-->
<!--#else -->
<!--#exec cgi="/cgi-bin/testtags.pl"-->
<!--#endif -->

#if expr = "${SERVER_SOFTWARE} = /Apache/"
#exec cgi="./cgi-bin/testtags.pl"
#else
#exec cgi="/cgi-bin/testtags.pl"
#endif


</head>

<body>

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Hello Worlds - Web page....</p>
</body>
</html>
 
<script runat="Server" language="PerlScript">
if ($expr = $ENV{SERVER_SOFTWARE} = /Apache/i) {
eval(`.\\cgi-bin\\testtags.pl`);
else {
open CGI "<<.\\cgi-bin\\testtags.pl";
eval(CGI)="\\cgi-bin\\testtags.pl";
}
if ($expr = $ENV{SERVER_SOFTWARE} = /Apache/i) {
eval(`.\\cgi-bin\\testtags.pl`);
}
else {
eval(".\\cgi-bin\\testtags.pl");
}
</script>
hope this help
 
Hi Thanks

I'll give this a go.....

Appreciate the effort :)

Cheers
Jerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top