Newbie "Hello, World" problem

Discussion in 'Perl Misc' started by NullBock, Aug 8, 2005.

  1. NullBock

    NullBock Guest

    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
    NullBock, Aug 8, 2005
    #1
    1. Advertising

  2. NullBock

    Brian Wakem Guest

    Tim Hammerquist wrote:

    > NullBock <> 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
    Brian Wakem, Aug 8, 2005
    #2
    1. Advertising

  3. NullBock

    NullBock Guest

    I'm using White Box Enterprise on a VPS.
    NullBock, Aug 8, 2005
    #3
  4. NullBock

    Paul Lalli Guest

    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
    Paul Lalli, Aug 8, 2005
    #4
  5. NullBock

    Guest

    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
    , Aug 8, 2005
    #5
  6. NullBock

    NullBock Guest

    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.
    NullBock, Aug 8, 2005
    #6
  7. NullBock

    Paul Lalli Guest

    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
    Paul Lalli, Aug 8, 2005
    #7
  8. NullBock

    Big and Blue Guest

    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.
    Big and Blue, Aug 11, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vijay
    Replies:
    8
    Views:
    701
  2. nospam

    Newbie: error loading Hello World

    nospam, Oct 3, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    358
    Alexey Smirnov
    Oct 3, 2007
  3. Roy
    Replies:
    6
    Views:
    600
    Roedy Green
    Jan 7, 2008
  4. Dimedrol
    Replies:
    0
    Views:
    313
    Dimedrol
    Jan 25, 2008
  5. Larry
    Replies:
    27
    Views:
    424
    Michele Dondi
    Jan 25, 2005
Loading...

Share This Page