httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Gration <rich...@zync.co.uk>
Subject Re: [users@httpd] Scripts cannot be executes
Date Sun, 07 Mar 2004 14:11:03 GMT
Hendrik-Jan van der Waal wrote:
> LS.
> 
> I'll keep this short because I'm not sure if this is the right place.
> 
> My site (www.pick.nl) uses a lot of perl scripts. Every now en than users
> get an internal server error. In the error log of apache, which I got from
> my ISP, the internal server error is a result of a premature end of
> headers, which is caused bij a memory allocation error (Can not exec
> scriptname.cgi)
> 
> My ISP doesn't know why the error occurs, there is enough memory. Is there
> any one who recognizes this problem. Is this a configuration problem or
> are my scripts  faulty?

The usual cause of this error is line end characters. When the cgi is 
uploaded, there are a variety of reasons why the file could end up on 
the (Unix) server with CRLF line terminators (CR == carriage return == 
ascii char 13 == Ctrl+M == ^M). The shebang line ends up being:

#!/usr/bin/perl^M

There is unfortunately no file called /usr/bin/perl^M on unix systems, 
just one called /usr/bin/perl. This is why the exec fails. Fortunately 
the fix is easy. You can:

Either
1) Specify the shebang line as "#!/usr/bin/perl -w" - this pushes the 
spurious ^M to after the -w so that the name of the perl executable is 
preserved. (not recommended)
Or
2) Edit the file once it is on the server and save it in unix format (LF 
line terminators), or use dos2unix (very tedious and easy to forget)
Or
3) Sort out your Windows editing and ftp programs so that the LF line 
terminators are preserved during editing and transfer (the "right" way)
Or
4) Stop using Windoze. (recommended - YMMV ;-) )

HTH
Rich


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message