-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
pythonbrian wrote:
> I am new to apache but I am learning quickly but recently I have been
> trying to learn database interaction. I developed a simple python
> script but I keep getting an error message (internal server error 500)
> when I load the web page. The apache error log file shows the
> following information and my permissions on the file appear to be
> okay. I think I have a configuration problem in apache but I don't
> know what to do ... any thoughts:
>
> --------------------------------------------------------------------
>
> [Thu Feb 07 15:49:50 2008] [error] [client 127.0.0.1] (2)No such file
> or directory: exec of '/var/www/cgi-bin/fig17_27.py' failed
> [Thu Feb 07 15:49:50 2008] [error] [client 127.0.0.1] Premature end of
> script headers: fig17_27.py
>
> --------------------------------------------------------------------
>
> brxxxxsh@ubuntu:/var/www/cgi-bin$ ls -al fig17_27.py
> -rwxr-xr-x 1 root root 3488 2008-02-07 15:49 fig17_27.py
>
> --------------------------------------------------------------------
>
> Contents of file: fig17_27.py (this executes fine from the command
> line using the command: "python fig17_27.py" and I see data from the
> database, so I am assuming the program/script is okay.
> Also, this is a example/tutorial from a Deitel text book ...
>
> #!/usr/local/bin/python
Sorry I'm too sleepy to read the whole of the post.
Can you do two thinngs?
1.
Don't leave the file owned as root:root. That's just *ASKING* for trouble.
2.
Check that you're not using windows line breaks.
With CGI scripts the webserver will fork()/execv() the shell on the
first line of the script (#!/usr/local/bin/python).
However, with windows line breaks the character before the LF is a \r
(0x0d). Take a look at the script using the 'od' program with the
arguments -xc to get hex/character output).
My guess is that's what's going wrong, so the script can't be executes
because the shebang line is wrong.
If you're using vim, keep 'set fileformat=unix' in your ~/.vimrc.
- --
The CAT5 to the Ultra 5 is down because of Brian Bird.
AOL is charging the omega 13 device.
:: http://www.s5h.net/ :: http://www.s5h.net/gpg.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla -
http://enigmail.mozdev.org
iD8DBQFHq6zd4dyr7s6PRYgRAjLeAJ9gyVioDUE8DeQFhjWPCSsf7zOGZQCghkBL
TwVg53Qif6Jm6x3QhmWgrTk=
=es+e
-----END PGP SIGNATURE-----