[thelist] perl scripts causing server error

Means, Eric D eric.d.means at boeing.com
Tue Apr 16 17:17:01 CDT 2002


> Eric, I tried env command in Telnet, and I got permission denied. When I
> tried the other 'working' script, I got the expected output.

> The following is an extract of the directory listing:

[snip]

> This is the output:
> [I have no name!@xxx cgi-bin]$ env hi.pl
> env: hi.pl: Permission denied
> [I have no name!@xxx cgi-bin]$ env hi.cgi
> env: hi.cgi: Permission denied
> [I have no name!@xxx cgi-bin]$ env solidform.cgi
> 2002-04-16 23:00:01 Failed to get user name for uid 5903
> Content-type: text/html
>
> <html><head><title>Thank you for mailing Solid Auto UK!</title></head> ...
>
> There's obviously some issue going on here, but not being a *nix man, I'm
> struggling.

1)  I should have been more specific.  :)  I'm going to put this in a tip as
it's quite useful.
<tip type="Debugging cgi scripts on *nix servers" author="Eric Means">
If you're getting a generic "500 Server Error" from a CGI script, one way to
see what errors the script is actually producing is the 'env' command.  This
allows you to simulate environment variables when running the script.  This
is helpful since, at least with Apache on *nix servers, script parameters
are passed as environment variables.
The general format of the env command is:
env name=value name=value name=value ... script.pl
Where 'name' is replaced by the name(s) of the variables you want to set and
'value' by the values of those variables.

For instance, the querystring passed in the URL is generally passed as the
environment variable QUERY_STRING.  In order to simulate a querystring when
running the script from the command line, use the following:
env QUERY_STRING=myvar1=myval1&myvar2=myval2 script.pl
In this case, the script will react as if called by the URL
http://www.my.server.com/cgi-bin/script.pl?myvar1=myval1&myvar2=myval2 but
will spit its output to the console, which can be helpful in determining
precisely what the problem is.
</tip>

2)  Permission denied... are you *absolutely* sure that the #!/path/to/perl
line is correct in the hi.pl script?  Did you edit the script(s) in a
Windows (or Mac) editor and then copy them or upload them to the server
(which would imply incorrect line-termination characters)?  The user, group,
and perms are all correct, so I don't see the problem there.



More information about the thelist mailing list