Perl CGI not working although shell script CGI's do

Perl CGI not working although shell script CGI's do

Post by Paul Seeli » Thu, 11 Sep 1997 04:00:00



I've installed Apache 1.2.1. on HP-UX B.10.01 A 9000/735 running as
user "www" in "group #33" as recommended for HP-UX. It is invoked with
"/usr/local/sbin/httpd -f /usr/local/lib/apache/conf/httpd.conf".

The problem in queston is that it simply can't execute Perl based CGI
scripts and i don't understand why even after having consulted the
relevant FAQ's, the documentation on "www.apache.org" and various
other information resources about CGI on the net:

------------bite-here--------------
Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.


and inform them of the time the error occurred, and anything you might
have done that may have caused the error.
------------bite-here--------------

The CGI script to be blamed which has produced this error is
"/usr/local/lib/apache/cgi-bin/printenv":

------------bite-here--------------
#! /usr/local/lib/perl5.004/bin/perl

print "Content-type: text/html\n\n";
while (($key, $val) = each %ENV) {
        print "$key = $val<BR>\n";

Quote:}

------------bite-here--------------

The entry in the CGI error log states for this:

------------bite-here--------------
%% [Wed Sep 10 11:59:48 1997] GET /cgi-bin/printenv HTTP/1.0
%% 500 /usr/local/lib/apache/cgi-bin/printenv
%request
Host: fjord.imsd.uni-mainz.de
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Via: 1.0 www-cache.netz.klinik.uni-mainz.de:80 (Squid/1.1.10)
X-Forwarded-For: unknown
Cache-control: Max-age=259200
%response
%stderr
exec of /usr/local/lib/apache/cgi-bin/printenv failed, reason: Exec
format error (errno = 8)
------------bite-here--------------

The location of the perl binary is correctly inserted as stated by
`which perl`: "/usr/local/lib/perl5.004/bin/perl".

The relevant configuration entry in "access.conf" is:

------------bite-here--------------
<Directory /usr/local/lib/apache/cgi-bin>
AllowOverride None
Options All
</Directory>
------------bite-here--------------

The relevant configuration entry in "http.conf" is:

------------bite-here--------------
ServerRoot /usr/local/lib/apache
------------bite-here--------------

The relevant configuration entry in "srm.conf" is:

------------bite-here--------------
ScriptAlias /cgi-bin/ /usr/local/lib/apache/cgi-bin/
ScriptLog /usr/local/lib/apache/logs/cgi.log
AddHandler cgi-script .cgi
------------bite-here--------------

Output of "/usr/local/sbin/httpd -l" is:

------------bite-here--------------
Compiled-in modules:
  http_core.c
  mod_env.c
  mod_log_config.c
  mod_mime.c
  mod_negotiation.c
  mod_include.c
  mod_dir.c
  mod_cgi.c   <---------<<<<
  mod_asis.c
  mod_imap.c
  mod_actions.c
  mod_userdir.c
  mod_alias.c
  mod_access.c
  mod_auth.c
  mod_auth_anon.c
  mod_usertrack.c
  mod_browser.c
------------bite-here--------------

Note that CGI scripts based on standard bourne shell scripting run
just fine.

What am i doing wrong? What have i overlooked? Did i provide enough
information for making the problem evident?

                                 Thank you, P. *8^)
--

   African Music Archive - Institute for Ethnology and Africa Studies
   Johannes Gutenberg-University   -  Forum 6  -  55099 Mainz/Germany
   Our AMA Homepage  in  the WWW at  http://www.uni-mainz.de/~bender/

 
 
 

Perl CGI not working although shell script CGI's do

Post by Paul Seeli » Fri, 12 Sep 1997 04:00:00




> >The problem in queston is that it simply can't execute Perl based CGI
> >scripts and i don't understand why even after having consulted the
> >relevant FAQ's, the documentation on "www.apache.org" and various
> >other information resources about CGI on the net:
> Try running it from the command line.  Try running your perl
> interpreter by itself (ie. /path/to/perl).  This looks like
> a problem with the way perl is installed.  

Perl does work fine by itself when invoked from command line and the CGI
scripts in question work fine when run manually.

                           Even more puzzled, P. *8^)
--

   African Music Archive - Institute for Ethnology and Africa Studies
   Johannes Gutenberg-University   -  Forum 6  -  55099 Mainz/Germany
   Our AMA Homepage  in  the WWW at  http://www.uni-mainz.de/~bender/

 
 
 

Perl CGI not working although shell script CGI's do

Post by Marc Slemk » Fri, 12 Sep 1997 04:00:00



Quote:>I've installed Apache 1.2.1. on HP-UX B.10.01 A 9000/735 running as
>user "www" in "group #33" as recommended for HP-UX. It is invoked with
>"/usr/local/sbin/httpd -f /usr/local/lib/apache/conf/httpd.conf".
>The problem in queston is that it simply can't execute Perl based CGI
>scripts and i don't understand why even after having consulted the
>relevant FAQ's, the documentation on "www.apache.org" and various
>other information resources about CGI on the net:

Try running it from the command line.  Try running your perl
interpreter by itself (ie. /path/to/perl).  This looks like
a problem with the way perl is installed.  
 
 
 

Perl CGI not working although shell script CGI's do

Post by Paul Seeli » Fri, 12 Sep 1997 04:00:00




> > ------------bite-here--------------
> > #! /usr/local/lib/perl5.004/bin/perl

> > print "Content-type: text/html\n\n";
> > while (($key, $val) = each %ENV) {
> >         print "$key = $val<BR>\n";
> > }
> > ------------bite-here--------------
> What happens if you execute the script from your normal shell
> (it should output all your env variables)?
> Have you check permissions on your perl-binary and your script?

As an interesting side note this same script with path adapted to
"/usr/bin/perl" runs just fine on a Debian Linux system using "apache-1.1.3"
and "perl-5.003": "http://ietpd1.sowi.uni-mainz.de/cgi-bin/printenv".

                          Almost losing hope, P. *8^)
--

   African Music Archive - Institute for Ethnology and Africa Studies
   Johannes Gutenberg-University   -  Forum 6  -  55099 Mainz/Germany
   Our AMA Homepage  in  the WWW at  http://www.uni-mainz.de/~bender/

 
 
 

Perl CGI not working although shell script CGI's do

Post by Paul Seeli » Fri, 12 Sep 1997 04:00:00




> > ------------bite-here--------------
> > #! /usr/local/lib/perl5.004/bin/perl

> > print "Content-type: text/html\n\n";
> > while (($key, $val) = each %ENV) {
> >         print "$key = $val<BR>\n";
> > }
> > ------------bite-here--------------
> What happens if you execute the script from your normal shell
> (it should output all your env variables)?

I forgot to say that all perl scripts not working with apache do work
flawlessly when executed manually on the shell prompt. The example script
here does print out the environment variables as expected.

Quote:> Have you check permissions on your perl-binary and your script?

Both are "-rwxr-xr-x" and the cgi-scripts are owned by the user "www". But
the latter doesn't really seem to matter as other non perl CGI scripts seem
to be working regardless of their ownership.
                                             Thank you, P. *8^)
--

   African Music Archive - Institute for Ethnology and Africa Studies
   Johannes Gutenberg-University   -  Forum 6  -  55099 Mainz/Germany
   Our AMA Homepage  in  the WWW at  http://www.uni-mainz.de/~bender/
 
 
 

Perl CGI not working although shell script CGI's do

Post by Paul Seeli » Sat, 13 Sep 1997 04:00:00



> I've installed Apache 1.2.1. on HP-UX B.10.01 A 9000/735 running as
> user "www" in "group #33" as recommended for HP-UX. It is invoked with
> "/usr/local/sbin/httpd -f /usr/local/lib/apache/conf/httpd.conf".
> The problem in queston is that it simply can't execute Perl based CGI
> scripts and i don't understand why even after having consulted the
> relevant FAQ's, the documentation on "www.apache.org" and various
> other information resources about CGI on the net:
> ------------bite-here--------------
> Internal Server Error

[shortened for brevity]

Quote:> ------------bite-here--------------
> The CGI script to be blamed which has produced this error is
> "/usr/local/lib/apache/cgi-bin/printenv":
> ------------bite-here--------------
> #! /usr/local/lib/perl5.004/bin/perl
> print "Content-type: text/html\n\n";
> while (($key, $val) = each %ENV) {
>         print "$key = $val<BR>\n";
> }
> ------------bite-here--------------

[...]
> The location of the perl binary is correctly inserted as stated by
> which perl: "/usr/local/lib/perl5.004/bin/perl".
[...]
> Note that CGI scripts based on standard bourne shell scripting run
> just fine.

The reason for the Perl CGI scripts not executing properly was the line
"#! /usr/local/lib/perl5.004/bin/perl" indicating the path to the Perl
executable: it was simply to long by exceeding 32 characters! The man page
to "perlrun" states the following:
------------bite-here--------------
   Because many operating systems silently chop off kernel interpretation
   of the #! line after 32 characters, some switches may be passed in on
   the command line, and some may not; you could even get a "-" without
   its letter, if you're not careful.  You probably want to make sure
   that all your switches fall either before or after that 32 character
   boundary.  Most switches don't actually care if they're processed
   redundantly, but getting a - instead of a complete switch could cause
   Perl to try to execute standard input instead of your script.  And a
   partial -I switch could also cause odd results.
------------bite-here--------------

Obviously HP-UX is one of the OS's having problems with such a 32 characters
boundary. Making a symlink "/usr/local/bin/perl" to the actual Perl binary
was the solution in this case! :-)
                                   Thanks for your support, P. *8^)

--

   African Music Archive - Institute for Ethnology and Africa Studies
   Johannes Gutenberg-University   -  Forum 6  -  55099 Mainz/Germany
   Our AMA Homepage  in  the WWW at  http://www.uni-mainz.de/~bender/

 
 
 

1. Perl CGI script gets CGI params as ARGV arguments under Apache2

Hi,

recently we installed Apache2 for tests with our web scripts and
discovered that the webserver calls them with all given CGI parameters
as one string argument. This was discovered because one script trys to

contains any entry... and in fact, under Apache2 it does! :-(
We don't know if this is a change in behaviour on behalf of the
webserver or if this is simply a Apache2 missconfiguration.
Does anybody out there has an answer to the question how we can get
back to the old behaviour? Or is this completely impossible?

Thanks in advance, best regards,
J?rn Janoschek.

2. IPSEC, ipchains, and ipmasqadm portfw

3. CGI and Perl scripts not working

4. Device driver modules ?

5. Can't seem to Get CGI/Perl Scripts to work

6. Is there dslib for linux?

7. /cgi-bin/phf /cgi-bin/test-cgi /cgi-bin/handler

8. '(no

9. shell cgi script and mod_perl cgi

10. apache: cgi script not in cgi-bin

11. sigsegv by process started via bourne shell by perl cgi script on apache

12. counter.cgi in cgi-bin won't work

13. Perl CGI written in DOS - won't run