For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2007 > cgi - perl-w OK but per not









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cgi - perl-w OK but per not
CoffeeBean

2007-04-24, 3:58 am

Just installed mod_perl2 on apache2 on ubuntu

When running a script (all.pl and .cgi set to ExecCGI in apache.conf)
that starts with;

#!/usr/bin/perl -w

I get a warning but it runs:

[Mon Apr 23 20:13:23 2007] [error] [client 127.0.0.1] Use of
uninitialized value in string eq at /var/www/test2/Tester.cgi line
399.

however with just:

#!usr/bin/perl

[Mon Apr 23 20:14:18 2007] [error] [client 127.0.0.1] (2)No such file
or directory: exec of '/var/www/test2/Tester.cgi' failed
[Mon Apr 23 20:14:18 2007] [error] [client 127.0.0.1] Premature end of
script headers: Tester.cgi

and crash and burn.

can anyone help ?

usenet@DavidFilmer.com

2007-04-24, 7:58 am

On Apr 23, 8:27 pm, CoffeeBean <nick.u...@gmail.com> wrote
> can anyone help ?


I have a guess, but I need more info. Does your program include a
statement such as:

use CGI::Carp ...

?

--
David Filmer (htt[p://DavidFilmer.com)

Paul Lalli

2007-04-24, 7:58 am

On Apr 23, 11:27 pm, CoffeeBean <nick.u...@gmail.com> wrote:
> Just installed mod_perl2 on apache2 on ubuntu
>
> When running a script (all.pl and .cgi set to ExecCGI in apache.conf)
> that starts with;
>
> #!/usr/bin/perl -w
>
> I get a warning but it runs:
>
> [Mon Apr 23 20:13:23 2007] [error] [client 127.0.0.1] Use of
> uninitialized value in string eq at /var/www/test2/Tester.cgi line
> 399.
>
> however with just:
>
> #!usr/bin/perl
>
> [Mon Apr 23 20:14:18 2007] [error] [client 127.0.0.1] (2)No such file
> or directory: exec of '/var/www/test2/Tester.cgi' failed
> [Mon Apr 23 20:14:18 2007] [error] [client 127.0.0.1] Premature end of
> script headers: Tester.cgi
>
> and crash and burn.
>
> can anyone help ?


My guess is you wrote the script in Windows and transferred it in
binary format to Unix. Therefore, your script has windows-style
newlines. So when your shebang doesn't have anything following it,
you're actually trying to run "/usr/bin/perl\r", rather than "/usr/bin/
perl". It's this non-existing executable that results in "no such
file or directory". When you put the -w on that line, you remove the
\r from the name of the executable, and Perl doesn't care about
whitespace, so it doesn't mind you putting a \r after the -w switch.

Fix your line endings. `man dos2unix`

Paul Lalli

CoffeeBean

2007-04-25, 6:58 pm

Yep, it was line endings. Probably a classic newbie blunder.

Thanks for replying.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com