python 2.0 won't run scripts with \r\n line termination on RH7?

Clarence Gardner clarence at
Sun Feb 11 23:25:48 CET 2001

>"Mike Carifio" <carifio.nospam at> wrote in message
>news:t8c7a69cqerq7c at
>> I have a network of Linux and Windows machines. On a Windows box, I have
>> several python scripts which I'd also like to run on the Linux machines.
>> I've
>> smbmounted the Windows share to see the scripts, but having been created
>> on the Windows box, the line termination in those files is \r\n. When I
>> to execute the script, say 'start', I get:
>> bash: ./ No such file or directory
>> When I "clean up" with tr - tr -d '\r' < >
>> it
>> runs. So it seems like python 2 can't compensate for wierd Windows line
>> terminators. Any workarounds, other than 'tr'? Pl. advise. Tx.

Most likely, this is not a Python 'problem'; the 'problem' is with Linux.
The first line of your script has a '#!<path to Python>' and there is a
carriage return at the end of the word 'python'.  Since you don't have
a program on your system called 'python\r', it won't run.

The best thing to do is simply use newlines only, since it will work on
both.  I was going to say that you could also just put a space after the
word python on your shebang line (#!python \r), but then Python tries
to open '\r' as a script, because Linux supplies the \r as a command
line argument.  Sometimes, you just can't win....

More information about the Python-list mailing list