Re: dropping messages?

2002-10-02 18:48:54
On October 2, 2002 at 18:55, Chad Kouse wrote:

I'm attaching my resource file...

There is not much to it, just a MIMEFILTERS setting.  It looks okay.

I run the script like this $htmlmsg = `/usr/bin/mhonarc -single
-rcfile=/etc/mimefilters /tmp/mk_tmp001.msg`;
The '=' should be a space.

see anything wrong ?

I tend to avoid using the backtick operator in Perl, except for very
trivial things (I'm wondering if it could be a source of your "hangs").
Main reasons are performance and security.  I'd use something like
the following:

  my $htmlmsg = "";
  my @cmd = (
    '-rcfile', '/etc/mimefilters',

  my $child_pid = open(MHONARC, '|-');
  if ($child_pid) {   # parent
    local $_;
    while (<MHONARC>) {
      $htmlmsg .= $_;
    if (!close(MHONARC)) {
      die qq/ERROR: Non-zero exit from "@cmd": $?\n/);

  } else {      # child
    exec(@cmd) || die qq/ERROR: Cannot exec "@cmd": $!\n/;

The above avoids having the overhead of a calling a shell process and
avoids any messing shell meta-character problems.  The above could
be encapsulated into a general routine for capturing the output of
a program.

Now, to be be even more efficient, you could avoid execing mhonarc and
call it via its API.  For what you are doing, you will need the
IO::String module:

  use IO::String;
  require '';

  my $html_msg = IO::String->new;
  my @mha_args = ('-quiet',
                  '-rcfile', '/etc/mimefilters',
                  '-stdout', $html_msg,

  if (mhonarc::process_input(@mha_args)) {
    die qq/ERROR: mhonarc returned non-zero status: $mhonarc::CODE\n/;

  print ${$html_msg->string_ref};

MHonArc secretly supports the ability of passing a reference to a
file handle to the -stdout option in order to support embedded usage.


To sign-off this list, send email to majordomo(_at_)mhonarc(_dot_)org with the

<Prev in Thread] Current Thread [Next in Thread>