Newbie "Hello, World" problem

N

NullBock

So I'm trying to get my first PERL script working; here it is,
verbatim:

[start]
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";
[end]

Permissions look good :

-rwxr-xr-x 1 root root 79 Aug 8 05:10 first.pl

Running it via a web-browser shows an internal error :

http://easypeas.net/cgi-bin/first.pl

The log gives me the following message:
[Mon Aug 08 04:55:27 2005] [error] [client 1.2.3.4] (2)No such file or
directory: exec of '/var/www/cgi-bin/first.pl' failed
[Mon Aug 08 04:55:27 2005] [error] [client 1.2.3.4] Premature end of
script headers: first.pl

Running the script via the command line (./first.pl) results in a "bad
interpreter: No such file or directory" error; but the perl path is
corrent! Explicitly calling the perl interpreter (/user/bin/perl
first.pl) results in the proper output :

[start]
Content-type: text/html

Hello, World.
[end]

Any ideas?

Walter Gildersleeve
Freiburg, Germany
 
B

Brian Wakem

Tim said:
NullBock said:
The log gives me the following message:
[Mon Aug 08 04:55:27 2005] [error] [client 1.2.3.4] (2)No such file or
directory: exec of '/var/www/cgi-bin/first.pl' failed
[Mon Aug 08 04:55:27 2005] [error] [client 1.2.3.4] Premature end of
script headers: first.pl
Your path indicates you might be running the Apache httpd
included with OpenBSD. OpenBSD's apache runs in a chroot jail
by default. Therefore, anything not under /var/www is
inaccessible by the server.
HTH,
Tim Hammerquist


Mandrake/Mandriva uses the same path.
 
P

Paul Lalli

NullBock said:
So I'm trying to get my first PERL script working; here it is,
verbatim:

[start]
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";
[end]

Your first Perl (not PERL) script should probably not be a CGI script.
Learn to get Perl working on the command line first, then learn how to
program CGI. Just my opinion of course.
Running the script via the command line (./first.pl) results in a "bad
interpreter: No such file or directory" error; but the perl path is
corrent! Explicitly calling the perl interpreter (/user/bin/perl
first.pl) results in the proper output :

When my students get this error, the first thing I ask them is whether
or not they wrote their program in Windows and then transferred it (via
something other than FTP ASCII mode) to Unix. If this is the case, you
most likely have the wrong line endings, and you are attempting to
execute an interpreter named "/usr/bin/perl\r". If this is the case,
you can fix the line endings by running the dos2unix program that comes
standard with most Unix distrobutions. (Check its man page for more
details)

Just a random guess on my part. It may not be correct.

Paul Lalli
 
S

sopan.shewale

Hi,

Even I have see the similar problem in mandrake.

Just run dos2unix command on your script.. it should work fine---this
is temp. fix.
For permanent fix, recreate the cgi-bin directory.

This is because of vi command problem.. i think by default it creats
the dos file.

Regards,

--sopan shewale
 
N

NullBock

Thanks for the tips, it was in fact a DOS/UNIX problem. dos2unix did
the trick.
Your first Perl (not PERL) script

This is semantic, isn't it? PERL was (is) an acronym...I assume you
hold that it's in common-enough use that the Perl form is correct? I
could agree, but then I still see SCUBA now and again.
 
P

Paul Lalli

NullBock said:
Thanks for the tips, it was in fact a DOS/UNIX problem. dos2unix did
the trick.

Glad to hear it.
This is semantic, isn't it?
No.

PERL was (is) an acronym.

No, it wasn't and isn't. Please read:
perldoc -q difference.
..I assume you
hold that it's in common-enough use that the Perl form is correct?

No. I hold that Perl is the actual name of the language, and that PERL
has never been correct.
I could agree, but then I still see SCUBA now and again.

SCUBA is an acronym. It was created as a shortened way of saying "Self
Contained Underwater Breathing Appratus" (or similar - please let's not
start a thread about this if my memory isn't correct). Perl was the
name given by Larry Wall to his new language. It was only after the
fact that some people decided the letters might stand for anything in
particular. It is a retronym, not an acronym.

Paul Lalli
 
B

Big and Blue

NullBock said:
So I'm trying to get my first PERL script working; here it is,
verbatim:

[start]
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";
[end]

Why, having told teh client that it you will send text/html, do you
send plain text rather than html? Either:

a) set the type to text/plain or
b) send html.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top