Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Newbie "Hello, World" problem

Reply
Thread Tools

Newbie "Hello, World" problem

 
 
NullBock
Guest
Posts: n/a
 
      08-08-2005
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

 
Reply With Quote
 
 
 
 
Brian Wakem
Guest
Posts: n/a
 
      08-08-2005
Tim Hammerquist wrote:

> NullBock <(E-Mail Removed)> wrote:
>> 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.


--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
 
Reply With Quote
 
 
 
 
NullBock
Guest
Posts: n/a
 
      08-08-2005
I'm using White Box Enterprise on a VPS.

 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      08-08-2005
NullBock wrote:
> 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

 
Reply With Quote
 
sopan.shewale@gmail.com
Guest
Posts: n/a
 
      08-08-2005
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

 
Reply With Quote
 
NullBock
Guest
Posts: n/a
 
      08-08-2005
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.

 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      08-08-2005
NullBock wrote:
> Thanks for the tips, it was in fact a DOS/UNIX problem. dos2unix did
> the trick.


Glad to hear it.

> > Your first Perl (not PERL) script

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

 
Reply With Quote
 
Big and Blue
Guest
Posts: n/a
 
      08-10-2005
NullBock wrote:
> 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.



--
Just because I've written it doesn't mean that
either you or I have to believe it.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie with newbie questions JohnE ASP .Net 3 08-17-2009 10:10 PM
VONAGE Newbie w/newbie question New_kid@nowhere.new VOIP 0 08-11-2007 01:40 PM
another newbie question from another newbie.... Lee UK VOIP 4 05-17-2005 04:10 PM
newbie: cisco vlan newbie question No Spam Cisco 3 06-07-2004 10:02 AM
Newbie! I'm a newbie! What's wrong with this program? Id0x Python 4 07-20-2003 11:40 PM



Advertisments