Forum OpenACS Q&A: Response to CRLF Mac *nix DOS conversions

Collapse
Posted by Torben Brosten on
Hi Bob,

You ask: How deep do we have to go to make this work?  Is it just an issue with .adp files?

In short, it's not deep, but pervasive.

I regularly use/mix MacOS and *nix files (sprinkling in some MSWin/DOS). This is a regular barrier of any text-based file on *nix coming from a Mac (that is not prepared for *nix). Still, it is not a difficult barrier to overcome.

There is an elegant example tcl script for converting files to *nix EOLs included in the 2nd ed. of "Practical Programming in Tcl an Tk" by Welch --I don't know if it is in the 3rd ed. It recursively reads a whole file before writing. The example works for most small files (I think).

Recently, I had to convert a 500MB+ file, so I could use linux tools on a mail collection file (less, grep, etc.). Previous to conversion, these linux utilities assumed the file was one long line and did not work as I had "wished".  The linux machine froze while processing the file using the example script. (The Mac software crashed when reading the entire file also).  I patched together a script that bypasses memory requirements; it writes a line as it reads a line --crude and slow, but it works.