Newbie gets Internal Server Error, among others

Discussion in 'Perl Misc' started by Jessica Smith, Nov 4, 2003.

  1. I'm using Mac OS X, and I'm trying to run a script I copied from a
    tutorial. The script is online at
    http://www.elanus.net/cgi/examples.cgi/view/ex_0302.txt

    It's chmod'ed 755, just like it should be, and the sh-bang line is
    correct. Yet, when I run the program in Terminal, I get:

    ../mail_form.cgi: =: command not found
    ../mail_form.cgi: =: command not found
    ../mail_form.cgi: =: command not found
    ../mail_form.cgi: =: command not found
    ../mail_form.cgi: =: command not found
    ../mail_form.cgi: line 18: syntax error near unexpected token `qw:)'
    ../mail_form.cgi: line 18: `use CGI qw:)standard);'
    [Jessica-Smiths-Computer:/library/webServer/cgi-executables] jessicas%

    When I hit it in Explorer, I get an Internal Server Error, and then my
    error log produces this message:

    [Tue Nov 4 13:21:06 2003] [error] (8)Exec format error: exec of
    /Library/WebServer/CGI-Executables/mail_form.cgi failed
    [Tue Nov 4 13:21:06 2003] [error] [client 192.168.7.33] Premature end
    of script headers: /Library/WebServer/CGI-Executables/mail_form.cgi

    I've searched newsgroups, Perl references, CGI references and 2
    dead-tree Perl manuals, and I still have no idea what is causing the
    problem.

    Please help! Thanks.
     
    Jessica Smith, Nov 4, 2003
    #1
    1. Advertising

  2. Jessica Smith

    Ben Morrow Guest

    (Jessica Smith) wrote:
    > I'm using Mac OS X, and I'm trying to run a script

    <snip>
    > It's chmod'ed 755, just like it should be, and the sh-bang line is
    > correct. Yet, when I run the program in Terminal, I get:
    >
    > ./mail_form.cgi: =: command not found

    <snap>
    >
    > When I hit it in Explorer, I get an Internal Server Error, and then my
    > error log produces this message:
    >
    > [Tue Nov 4 13:21:06 2003] [error] (8)Exec format error: exec of

    <snop>

    The #! line is wrong.

    To prove this to yourself, run it in Terminal as 'perl mail_form.cgi'
    rather than './mail_form.cgi'.

    Do you have a space after the #!? You shouldn't.

    What line-ending are you using? I have no idea what the standard is on
    OS X (BSD would dictate \012, MacOS would dictate \015) but if it is
    not what the kernel wants (*probably* \012, as opposed to the \015
    your editor *may* be producing) then it likely won't work. perl
    doesn't care, of course.

    Ben

    --
    The cosmos, at best, is like a rubbish heap scattered at random.
    - Heraclitus
     
    Ben Morrow, Nov 4, 2003
    #2
    1. Advertising

  3. First of all, thank you so much for extending help.

    The #! line is right. There's no space after the exclamation point,
    and I did a "where perl" to check the directory.

    What's up with this line-ending stuff? I don't know what that does,
    where it is, what it should be, or how I could change it. I found
    this OS X "explanation" online (http://www.osxfaq.com/man/1/col.ws)
    but it didn't help much.

    Thanks again.
     
    Jessica Smith, Nov 5, 2003
    #3
  4. Jessica Smith

    Ben Morrow Guest

    Line-ending problems on Mac OS X

    [I should perhaps point out that this isn't a problem with perl: it's
    a problem with your text editor and your operating system. However...]

    (Jessica Smith) wrote:
    > What's up with this line-ending stuff? I don't know what that does,
    > where it is, what it should be, or how I could change it.


    Try this. Start in the directory containing my.cgi (or whatever it was
    called :) and run:

    perl -ne'/\015\012/ and die "DOSish"; /\015/ and die "Macish"; \
    /012/ and die "BSDish"' my.cgi

    (that command should be all on one line). Note the result: that tells
    you what your current line-endings are. Then run

    perl -pi -e's{\015|\015?\012}{\012}' my.cgi
    ../my.cgi

    If that fails, run

    perl -pi -e's{\012}{\015}' my.cgi
    ../my.cgi

    And if that fails (which it shouldn't), run

    perl -pi -e's{\015}{\015\012}' my.cgi
    ../my.cgi

    Then, just for interest's sake, run

    perl -e'printf "\\r eq \\0%o, \\n eq \\0%o\n", ord "\r", ord "\n"'

    Post the results.

    --
    For the last month, a large number of PSNs in the Arpa[Inter-]net have been
    reporting symptoms of congestion ... These reports have been accompanied by an
    increasing number of user complaints ... As of June,... the Arpanet contained
    47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] *
     
    Ben Morrow, Nov 5, 2003
    #4
  5. When I do a "where perl" it tells me usr/bin/perl, which is right
    where I'm telling the script to look. I'm on Mac OS 10.2.8 as well,
    using Perl 5.6.0, which was already on my machine.

    I am SO frustrated. Someone else said something about line endings...
    I don't know what that's all about. Any other ideas, or should I just
    continue beating my head against my lovely corkboard partition here?

    Thanks.
     
    Jessica Smith, Nov 6, 2003
    #5
  6. Jessica Smith <> wrote:

    > When I do a "where perl" it tells me usr/bin/perl, which is right

    ^^
    ^^
    > where I'm telling the script to look.



    Where is the leading slash?

    /usr/bin/perl


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Nov 6, 2003
    #6
  7. Jessica Smith

    Anno Siegel Guest

    Jessica Smith <> wrote in comp.lang.perl.misc:
    > I'm using Mac OS X, and I'm trying to run a script I copied from a
    > tutorial. The script is online at
    > http://www.elanus.net/cgi/examples.cgi/view/ex_0302.txt
    >
    > It's chmod'ed 755, just like it should be, and the sh-bang line is
    > correct. Yet, when I run the program in Terminal, I get:


    How do you run it? Show the exact call.

    > ./mail_form.cgi: =: command not found


    This message (and the following ones) say that you tried to run the
    script as an sh script. In the configuration statements, beginning
    with "$sendmail = '/usr/sbin/sendmail'; # where is sendmail?", sh
    tries to run "=" as a command, that's why it complains five times.
    And so on.

    If you didn't explicitly call it as "sh mail_form.cgi", that means the
    shebang line isn't recognized by your system.

    Anno
     
    Anno Siegel, Nov 7, 2003
    #7
    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. John Bonds
    Replies:
    2
    Views:
    2,750
    Amaryllis
    Aug 3, 2004
  2. fix
    Replies:
    7
    Views:
    378
  3. JAG
    Replies:
    0
    Views:
    318
  4. Tech HR
    Replies:
    0
    Views:
    276
    Tech HR
    Dec 19, 2006
  5. Travis
    Replies:
    3
    Views:
    373
Loading...

Share This Page