Web Software Architecture and Engineering – Life on the Bleeding Edge

As you guys may know, on one of my production boxes, I’ve been having CFMail issues. Details here.
Here is an image of the problem:
 CFMAIL Before
As well, I looked parsing the necessary cfmail files to get rid of defective line. But looking at ColdFusion and Java (and even .NET), nothing stood out.
So that was it! I needed a solid CFC to work with text files on a line by line basis. Enter FileByLine.CFC.
Here is some code!
<![CDATA[

<!—
Author: Sami Hoda
Email: sami bytestopshere.com
Blog: http://www.bytestopshere.com
Version: v0.1
Note: Comments appreciated!

Warning:
This code is provided as is.
I make no warranty or guarantee.
Use of this code is at your own risk.
READING OF LARGE FILES INTO ARRAYS FOR MANIPULATION CAN BE RISKY. RE-READ WARNING!

To Do:
– Optimization! I want it faster!
– Implement some sort of find capability… use Regex?

License:
Copyright 2009 Sami Hoda

Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
—>

]]>

And now the image shows:
CFMail After
Voila! Have fun. Comments welcome!
I’ll add this code to RiaForge shortly!
UPDATE: Code now on RiaForge, see http://filebyline.riaforge.org/.

Advertisements

Comments on: "Reading Text Files Through Line Number – A Solution" (6)

  1. Would:
    cat mailSpoolFileName|grep -v “${mailServer}”
    or similar not be easier ?

  2. Tom,

    That would be a *Nix solution, no?

    I wanted something generic I could use all over, not just for this cfmail issue as well.

  3. UPDATE: Code now on RiaForge, see http://filebyline.riaforge.org/.

  4. @Sami: No, not at all; cat, grep and friends are GNU tools, and available anywhere you can compile C 🙂 For instance, the Win32 versions are : http://gnuwin32.sourceforge.net/packages.html

  5. Tom,

    Hmmm. So in theory, I could write a CF scheduled task to go through each file in the Undelivr folder and run the cat command against it?

  6. Aye.
    I wouldn’t bother ColdFusion with this though, you can drive it all from a scheduled batch job.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: