Newbie + Linux + Apache + CGI + Python = Problem

Tim Roberts timr at probo.com
Wed Jan 3 01:54:52 EST 2001


"John F." <nospam at here.com> wrote:
>
>[5] in the cgi-bin dir I can NOT execute the python script with:
>./hello2.cgi  I get that it cannot find the file, BUT if I put a bogus
>command option after #!/usr/bin/python it FAILS with a Python usage prompt,
>so bash is finding python (and it is in the $PATH so it SHOULD).

(Raises hand and jumps annoyingly...)  I know, I know!

You can learn the answer by looking at the files in a binary editor.

The Perl script was created in Linux.  The Python script was created in
DOS/Windows and copied to Linux.  The lines in the Python script are
terminated with \r\n.  The exec loader doesn't know from \r, so it tries to
load "/usr/bin/python\r" and, predictably, does not find it.

Bring the file into vi; it will say "dos-format" at the bottom.  Do ":set
fileformat=unix" and ":w".
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list