Hi all –
I am running Python 2.6.2 in a Windows XP Pro environment. I am trying to write my first python/cgi script combo and they must execute on a Linux websever. After surfing the web I realize that MS-DOS and Unix systems use different methods to identify end-of-line information in text files (CR/LF vs. LF).
Is there a quick and simple way to convert my cgi script so that I can run in on the Linux server? I tried using a dos2unix file but don’t know enough about it to use it properly. Thanks.
redpython
0
Newbie Poster
Recommended Answers
Jump to PostYou can try this
def dos2unix(my_string): return my_string.replace("\r\n", "\n") # is it \n\r instead ? if __name__ == "__main__": dos_content = "line1\r\nline2\r\nline3\r\n" unix_content = dos2unix(dos_content) print repr(unix_content) """my output ---> 'line1\nline2\nline3\n' """
Note that there are numerous other potential issues: if your cgi scripts use the win32 …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.