Strange Python problem on Linux.

Thomas A. Bryan tbryan at
Wed Mar 1 04:20:41 CET 2000

Paul Jackson wrote:

> Along the lines of the previous suggestion that the "#! ..." line
> might have odd chars, in addition to trying 'cat -v', also try:
>     head -1 >
>     echo 'print "What's wrong?"' >>
>     chmod u+x
>     ./

Yep.  I tried them both for thoroughness.  There was a ^M (hex(13))
at the end of the #! line.  Linux was picking it up as part of the 
command to run.  I would have expected it to show up as extra whitespace 
or control characters when I traced the program, but it didn't.  I 
should have thought of cat -v (or Emacs hexl-mode) much earlier.

$ strace -o out.trace
strace: exec: No such file or directory
$ cat out.trace 
execve("./", [""], [/* 28 vars */]) = 0

One reason I never looked for the ^M was that I use Xemacs at work.
It shows the ^M.  Emacs seems to do the translation on the fly for 
me, so I didn't realize that the file had MS-corrupted line endings.

> That or just edit '', deleting the first line and rekeying
> it from scratch, if you are more interested in cures than in
> a diagnosis.

No.  I hate it when I fix something but don't know what was 
originally wrong.  If I know a problem's symptoms, cause, and 
solution, then I'll be more effective the next time I encounter it.

> =======================================================================
> I won't rest till it's the best ...        Software Production Engineer

afraid-of-professionals-who-rhyme-<wink>-ly yours


More information about the Python-list mailing list