How do I convert DOS (CR/LF) text files to Unix (LF) format?

If you publish a CGI script file (especially using Microsoft FrontPage), the file may have incorrect "line endings". Technically speaking, the file may have "CR/LF" (carriage return / line feed) endings instead of the correct Unix "LF" endings.

If such a script is run via your website, you'll see an "Internal Server Error" message. If you try running it from the command line, you'll see a "bad interpreter" error message.

It's possible to fix these scripts from the command line using the "dos2unix" program that we have on our servers, like this:

$ dos2unix -b file.cgi

The "-b" flag makes a backup of the file just in case something goes wrong.

If you need assistance doing this, we'll be glad to help; just contact us.