procmail
[Top] [All Lists]

Re: Undesirable characters in subject text

2003-05-27 14:50:22
At 12:41 2003-05-27 -0700, procmail(_at_)deliberate(_dot_)net did say:

=> Have you considered invoking this at a commandline.  Do you know that the
=> shell will automatically expand wildcards?
        <snip>
=> That single apostraphe can be a problem for you as well, so try:

        Ok, so I'm very shell impared, I'm sorry. I'll take it
from your rhetorical question and a quick commandline test (wow)
that my problems are related to using echo and "special"
characters such as wild cards.

I'm guessing that you didn't try the third invocation, as suggested (or that you didn't run ANY of them). It's a learning exercise, and most people learn by doing. Please actually try the shell invocations and see what they do, and you might gain a better understanding of them.

        Could someone please show me a way, hopefully within
procmail, to "cleanup" the text of a subject line, captured in a
variable called SUBJECT, such that I can write it out in a single
line record to my .txt file for later dbase manipulation? In my
case, truncation is preferrable to external program calls.

| echo "$SUBJECT" >> somefile

You may want to use:

| echo -n "$SUBJECT" >> somefile

Which would omit the trailing newline which echo would otherwise tack onto the emitted text.

You're going to have a difficult time filtering out characters that may appear in multiple locations within the string - a simple match operator would allow you to bracket the text, but that's likely to produce an undesireable result more often than not whenever there is a symbol you wish to omit. You could probably do it with a recursive INCLUDERC procmail recipe, but the overhead could (not to mention the complexity) end up being a lot more than simply invoking a program such as sed or tr, which are much better suited to such a task.

I'm wondering how you're ensuring that components from simultanious messages don't interleave in your dbase file, or is the only field the subject? Perhaps simply passing the message to a compiled C program might be the best way to deal with cleanup and writing of the data in one shot (as well as minimizing the overhead associated with multiple shell invocations - keep in mind that "echo" itself is a program you must invoke - so writing your own helper would take its place, meaning you'd have little difference in effective overhead, esp if you can do your entire operation in one invocation instead of (as I suspect) multiple invocations.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail