You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Hendrik-Jan van der Waal <h...@vdwaal.net> on 2004/03/06 16:47:17 UTC

[users@httpd] Scripts cannot be executes

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?

Thanks in advance for any suggestion!

Hendrik-)an

---------------------------------------------------------------------
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


Re: [users@httpd] Scripts cannot be executes

Posted by Hendrik-Jan van der Waal <h...@vdwaal.net>.
> 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
>
>

This is not the problem. The script works fine 90% of the time. It has
something todo with the amount of memory availeble for the httpd.
For your info, my main workstation is running on Suse, I´ve a debian
server and my favorite editor is vi(m).
Thank you very much for the suggestions.
Hendrik-Jan

---------------------------------------------------------------------
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


Re: [users@httpd] Scripts cannot be executes

Posted by Richard Gration <ri...@zync.co.uk>.
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