[Mimedefang] external filter

Jeroen Beerstra jb at scorpion77.cjb.net
Sat Nov 9 16:44:01 EST 2002


I apologise for my previous kind of silly questions. It was really time 
to rtfm :)

Now all works like desired but I'm a bit puzzeled about how an external 
filter should work. According to the mimedefanf-filter manpage the 
filter must take FILTEROUTPUT as input and produce FILTEROUTPUT all in 
the current directory. So I changed the supplied word-to-html shell 
script a bit to convert a wordfile to a html file+ png images and to 
create a zip file with all resluting files. First I tries this:

word-to-html
------------
#!/bin/sh
# MIMEDefang filter to convert MS Word documents to HTML

# No core wordfiles, thanks!
ulimit -c 0

# Don't spend more than 30s CPU time on the job
ulimit -t 60

prog="/usr/local/bin/wvHtml"
if test -x $prog ; then
     $prog --targetdir=./ ./FILTERINPUT wordfile >> /var/log/word-to-html
     mv -f wordfile wordfile.html > /dev/null
     zip word_attachement wordfile*.* > /dev/null
     mv -f word_attachement.zip FILTEROUTPUT > /dev/null
fi

exit 1
------------

This didn't work and produced a zipfile word_attachement.zip which in 
reality was the original word attachement. However when I changed the 
script to copy the zipfile to a directory before renaming it, the 
correct zipfile was placed in the directory but not in the e-mail. So 
I'm a bit confused why the zipfile gets lost.

I then tried a different approach:

word-to-html
------------
#!/bin/sh
# MIMEDefang filter to convert MS Word documents to HTML

# No core wordfiles, thanks!
ulimit -c 0

# Don't spend more than 30s CPU time on the job
ulimit -t 60

exec /usr/local/bin/word-to-html.cmd

exit 1
------------

word-to-html.cmd
----------------
#!/bin/sh
prog="/usr/local/bin/wvHtml"
if test -x $prog ; then
     $prog --targetdir=./ ./FILTERINPUT wordfile >> /var/log/word-to-html
     mv -f wordfile wordfile.html > /dev/null
     zip word_attachement wordfile*.* > /dev/null
     mv -f word_attachement.zip FILTEROUTPUT > /dev/null
fi
----------------

To my surprise this did work. I send a test mail with a wordfile with 
some graphics attached which was nicely converted to a zipfile with a 
html file and png graphics.

The only difference I see is the first approach uses 1 file and the 
second 2. Besides this I see 2 scripts that both take FILTERINPUT as 
input and produce a single file FILTEROUTPUT as output.

Any ideas, anybody?

-- 
Jeroen Beerstra
--

jb at scorpion77.cjb.net

PGP Key ID: 30146D2E




More information about the MIMEDefang mailing list