Python Source Format

Problem

$ ./b96902123-A3.py < input.txt
: No such file or directory

Note: The sample problem exists if you transfer a source file with UNIX Linefeeds (\n) to a
Windows PC. The python interpreter on windows expects (CRLF: \r\n)

Cause of the problem

File was uploaded in Binary instead of ASCII mode (e.g. my current Filezilla Config didn't have a
py configuration and even after I added it, Filezilla still uploads the file in binary mode).

xxd fileWithCRLF:

0000000: 2321 2f75 7372 2f62 696e 2f65 6e76 2070  #!/usr/bin/env p
0000010: 7974 686f 6e0d 0a0d 0a23 3d3d 3d3d 3d3d  ython....#======

xxd filewithLF:

0000000: 2321 2f75 7372 2f62 696e 2f65 6e76 2070  #!/usr/bin/env p
0000010: 7974 686f 6e0a 0a23 3d3d 3d3d 3d3d 3d3d  ython..#========

Solution

$ dos2unix b96902123-A3.py

VI Solution

:set ff=unix
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License