Web Hosting Talk







View Full Version : I feel old and rusty - CGI environment variables?


KGIII
06-08-2006, 09:52 AM
Server blah blah... Pretty standard LAMP stack. CHMODed every possible combination. I'm pretty sure I missed something.

Why won't this run?


#!/usr/bin/perl

print "Content-type: text/plain\n\n";
for (keys %ENV) {
print "$_ => $ENV{$_}\n";
}


Path is correct but I get errors... I get odd errors too, it tells me that the directory's writable by other. I fix it. It tells me that I don't have permission.

Did I miss something in between now and the last time (years ago) I was into Perl at any great level? I've tried writing it with a full set of variables. I'd tried it as small as I can make it - like the above. I think I've tried it with every possible set of permissions and ever rational path.

It's just Apache 1.3.36 and Perl 5.8.7... From inside the control panel I can pull the Perl modules easily enough and path to sendmail and Perl is right there but I was hoping to show it in the FAQs for pre-sales questions.

Thoughts? I'm missing something obvious aren't I?

KGIII

Premier
06-09-2006, 12:03 PM
I don't see anything wrong with that script so I ran it on one of my sites and it worked fine. I'm using pretty much the same Apache and Perl.

Are you trying to add this to the cPanel skin, or just have a link to it?

dmspilot
06-10-2006, 12:13 AM
Does your Apache installation have SuExec enabled? If so, the owner and group of the script would have to be the same as the Apache user.

chown username filename
chgrp username filename

Website Rob
06-10-2006, 06:47 PM
Perhaps a little more detail in the code might help?

#!/usr/bin/perl

print "Content-type: text/html\n\n";

print "<html><head><title>Server Enviroment Variables</title></head><body>";
print "<h2>Enviroment Variables</h2>";
print "<hr>\n";

foreach $evar(keys (%ENV)) {
print "<b>$evar:</b> $ENV{$evar}<br>";
}
print "</body></htm>";


1;

OverlordQ
06-10-2006, 09:53 PM
And get in the habit of using warnings and strict mode for all projects.