Bhikku,

I didn't understand the first explanation either, so I'm glad you
clarified this.


On Sat, 14 Oct 2000 [EMAIL PROTECTED] wrote:

= On Sat, Oct 14, 2000 at 08:33:50AM -0300, Marco Shaw wrote:
= 
= Hi Marco,
= 
= Thanks for your response
= 
= > I'm sorry, but I don't understand what your ultimate result should be.  You
= > want to run this from an HTML (CGI) page, or you want to expand on the
= > footers, and maybe add a header as well?
= 
= Sorry for my poor explanation
= I run a regular pop server.
= 
= Most of my users use Outlook Express and the format is mostly in html
= so that they can use the local script Sinhala.
= 
= I want to add a footer to user's mail, mostly in html format,
= but sometimes in Text format.
= 
= The format of Outlook Express is as below:
= 
= Outlook first defines boundary. (this is different in each message)
= boundary="----=_NextPart_000_0120_01C033AD.8D13AE90"
= ----=_NextPart_000_0120_01C033AD.8D13AE90
= message in text format 
= ----=_NextPart_000_0120_01C033AD.8D13AE90
= message in html format.
= </BODY></HTML>
= ----=_NextPart_000_0120_01C033AD.8D13AE90--
= 
= 
= I need to add my footer to 2 places as shown below
= 
= boundary="----=_NextPart_000_0120_01C033AD.8D13AE90"
= ----=_NextPart_000_0120_01C033AD.8D13AE90
= message in text format 
= footer 1
= ----=_NextPart_000_0120_01C033AD.8D13AE90
= message in html format
= footer 2
= </BODY></HTML>
= ----=_NextPart_000_0120_01C033AD.8D13AE90--  
= 
= (the last -- indicates end of message)
= ...

Looks to me like a job for sed, something like

for ff in $file_descript
do
        # cludge for just finding the first instance of this string
        sed 's/^----=_NextPart/----=_NextPart/'
        # insert footer1
        sed 's/^----=_NextPart/$footer1\n/----=_NextPart/r'
        #insert footer 2
        sed 's/\<\/BODY\>\<\/HTML\>/$footer2\n/\<\/BODY\>\<\/HTML\>/r'
done

The backslashes are to make sed treat these special characters as
literals.

There's a better way to get to the second instance of "---NextPart" using
sed's addressing syntax, but I've used this part of (a very big) sed only
a couple times and couldn't help much with that just off the top of my
head.  If you have to do this for a *lot* of files (thousands or at least
many hundreds) or if you are going to do this on an ongoing basis, then
get yourself a book or two on sed and play around with the syntax.

If it were me and I had fewer than a couple hundred files to work this on,
I would write a macro in emacs to do it unless it were just for the pure
enjoyment of it.  Personally, there's too much other stuff in my life that
comes before personal enjoyment.


hth,
kf

-- 
My recommendation: Don't shop at Explorer Micro, Columbus, Ohio.

= > > ..... 



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to