ASCII text executable, with CRLF line terminators
<p>Good evening,</p>

<p>I'm currently enrolled in an introduction-course to python and have come across an issue that I haven't been able to solve. I'm sure it's a simple error somewhere in my code, but I haven't been able to find any questions on SO that solved my issue.</p>

<p><em>Strangely enough it compiles and runs fine when executing it from cygwin...</em></p>

<p><strong>I'm getting this error while validating through 3rd party tests (that I don't have access to):</strong></p>

<blockquote>
  <p>Python script, ASCII text executable, with CRLF line terminators</p>
</blockquote>

<p>This is my code: </p>

<pre><code>    height = float(input("What is the plane's elevation in metres? \r\n"))
    height = format(height * 3.28084, '.2f')

    speed = float(input("What is the plane's speed in km/h? \r\n"))
    speed = format(speed * 0.62137, '.2f')

    temperature = float(input("Finally, what is the temperature (in celsius) outside? \r\n"))
    temperature = format(temperature * (9/5) + 32, '.2f') 

    print("""\n########### OUTPUT ###########\n\nThe elevation is {feet} above the sea level, \n
you are going {miles} miles/h, \n
finally the temperature outside is {temp} degrees fahrenheit \n
########### OUTPUT ###########""".format(feet=height, miles=speed, temp=temperature)) 
</code></pre>

<p>And this is a cgi based on it (both are throwing the same error):</p>

<pre><code> #!/usr/bin/env python3
# -*- coding: utf-8 -*- 


# To write pagecontent to sys.stdout as bytes instead of string
import sys
import codecs


#Enable debugging of cgi-.scripts
import cgitb
cgitb.enable()


# Send the HTTP header
#print("Content-Type: text/plain;charset=utf-8")
print("Content-Type: text/html;charset=utf-8")
print("")


height = format(1100 * 3.28084, '.2f')

speed = format(1000 * 0.62137, '.2f')

temperature = format(-50 * (9/5) + 32, '.2f')


toPrint = """\n########### OUTPUT ###########\n\nThe elevation is {feet} above the sea level, \n
you are going {miles} miles/h, \n
finally the temperature outside is {temp} degrees fahrenheit \n
########### OUTPUT ###########"""

toPrint.format(feet=height, miles=speed, temp=temperature)

# Here comes the content of the webpage 
content = """&lt;!doctype html&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;Min redovisnings-sida&lt;/title&gt;
&lt;pre&gt;
&lt;h1&gt;Min Redovisnings-sida &lt;/h1&gt;




&lt;/pre&gt;

&lt;body&gt;
 {printer}
&lt;/body&gt;

"""


# Write page content
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
sys.stdout.write(content.format(printer=toPrint))
</code></pre>

<p>You need to convert CRLF to LF, to do so you can run this command:</p>

<pre><code>dos2unix your_file
</code></pre>

<p>If you need to apply that to a specific folder content, use the below command inside your folder:</p>

<pre><code>find . -type f -exec dos2unix {} \;
</code></pre>

<p>You need to install <strong>dos2unix</strong> package first:</p>

<pre><code>sudo apt-get install dos2unix
</code></pre>

python python-3.x