Page 1 of 1
Perl and IIS6 = Almost Working. HELP!
Posted: Thu Jan 12, 2006 8:39 pm
by raw
I have a perl site which is running on a Red Hat server here just fine but I'm consolidating our web servers here and some of our apps are .NET so I have to find a way to port our linux web apps over which isn't so bad since all of it is 'supposedly' supported on Windows as well.
Anyways, I have most of the site working and I checked the code (which works in Linux) but when I call an action it gets ignored and just shoots me to the default page instead of the specified one based off my URL input. Below is a code example
Code: Select all
if ($in{'action'} eq "loadnav" { &display_content }
Any one of these specific actions that gets requested in the URL gets ignored. Has anyone seen this in a Windows environment before? I've searched online and found nothing worth a shit.
Posted: Thu Jan 12, 2006 8:43 pm
by plained
naa i doen know man
but i wrote a story
raw went fishing and had a time the end
you like?
Posted: Thu Jan 12, 2006 8:47 pm
by diego
I don't really understand the problem: Whenever You submit an action, it refers You to a default-page, right?
Posted: Thu Jan 12, 2006 8:52 pm
by raw
Ok, remember the old Q3W URL? http://www.quake3world.com/cgi-bin/Ulti ... tion=intro
Because the action was intro it did a specific function based on the URL input.
Well, I'm doing the same thing but it's ignoring it and just loading the default page the CGI loads. IF that makes sense....
Posted: Thu Jan 12, 2006 8:57 pm
by R00k
I've been putting off learning perl, but I know I'm going to have to one of these days.

Posted: Thu Jan 12, 2006 8:59 pm
by plained
ok raw i went and thouroly read your reply
i doen see the story mentioned.
what imi missing?
Posted: Thu Jan 12, 2006 9:13 pm
by dmmh
so your webserver doesnt seem to handle GET requests properly aight?
I think you will find loads of awesome help here:
http://www.webmasterworld.com/forum13/
by far a better place to ask, awesome ppl, just dont post any links to your site as thats seen as advertising
webmasterworld is the place all pro's flock together, I am also there (not that I consider myself a pro), so maybe post there for additional help?
Posted: Thu Jan 12, 2006 10:02 pm
by Tormentius
R00k wrote:I've been putting off learning perl, but I know I'm going to have to one of these days.

Likewise.
Posted: Thu Jan 12, 2006 11:09 pm
by raw
I actually like Perl. It's quite simple.
On a side note, I wrote some small test code to test the functionality and eliminate the application and the problem still exists which tells me it is a Perl running on IIS problem. Hopefully it's just a setting.
Posted: Thu Jan 12, 2006 11:39 pm
by raw
riddla wrote:I seem to recall reading somewhere there are some perl functions which simply dont work on an IIS install. Perhaps you found one of them...
This will totally suck if this is the case.
Posted: Fri Jan 13, 2006 12:47 am
by raw
Nope, I got all of that.
Posted: Fri Jan 13, 2006 2:01 am
by ^misantropia^
1. Where is %in set and to what?
2. Try doing $in{'action'} =~ /^action/i instead of eq.
3. Post the source.
Posted: Fri Jan 13, 2006 4:08 am
by Seg
You could also try defining the literal to a string before the compare. They may perform string compares differently from Linux to Windows.
$dummy = "loadnav"
if $in('action') eq $dummy {}
Posted: Fri Jan 13, 2006 4:29 am
by raw
I had a couple of kinks in my test script which I wrote today to test the basic functions of the server. This appears to be working now but for some reason that other app still isn't which I'm going to have to look into.
Here's the working code
Code: Select all
#!/usr/bin/perl -w
if (length ($ENV{'QUERY_STRING'}) > 0){
$buffer = $ENV{'QUERY_STRING'};
@pairs = split(/&/, $buffer);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$in{$name} = $value;
}
}
print "Content-type: text/html\n\n";
if ($in{'action'} eq "go") { print "<H1>GO ACTION</H1>\n"; }
else { print "<H1>NO ACTION</H1>\n"; }
Posted: Fri Jan 13, 2006 5:43 am
by Seg
if ($in{'action'} eq "loadnav" { &display_content } is also missing a ) after "loadnav".
if ($in{'action'} eq "loadnav") { &display_content }
Posted: Fri Jan 13, 2006 10:16 am
by ^misantropia^
Warning: Perl Nazism ahead.
1. *Always* use -T (tainting) in CGI scripts[1]
2. Use strict and scope your variables with "my"
3. Use
mod CGI, don't reinvent the wheel
[1] Forces you to mark all user input "safe".
Code: Select all
#!/usr/bin/perl -Tw
use warnings FATAL => 'all';
use strict;
use CGI;
my $cgi = CGI->new;
print $cgi->header(-type => 'text/html');
print $cgi->h1($cgi->param('action') eq 'go' ? 'GO ACTION' : 'NO ACTION');