Newbie gets Internal Server Error, among others

J

Jessica Smith

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

Ben Morrow

I'm using Mac OS X, and I'm trying to run a script
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
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
 
J

Jessica Smith

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

Ben Morrow

[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...]

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

Jessica Smith

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

Tad McClellan

Jessica Smith said:
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
 
A

Anno Siegel

Jessica Smith said:
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
 

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

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top