[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dropping messages?



>   use IO::String;
>   require 'mhamain.pl';
>   mhonarc::initialize();
> 
>   my $html_msg = IO::String->new;
>   my @mha_args = ('-quiet',
> 		  '-single',
> 		  '-rcfile', '/etc/mimefilters',
> 		  '-stdout', $html_msg,
> 		  '/tmp/mk_tmp001.msg');
> 
>   if (mhonarc::process_input(@mha_args)) {
>     die qq/ERROR: mhonarc returned non-zero status: $mhonarc::CODE\n/;
>   }
> 
>   print ${$html_msg->string_ref};

did you mean to say if (!mhonarc::process_input(@mha_args)) ?

I did it the way you mentioned (throwing in the ! mentioned just above)
and I am having a hard time.  the rest of my script basically treats
$htmlmsg as a regular string, and now I'm getting all blanks inserted
into the databse (I'm shooting blanks :) )  I even tried making a new
variable and derefrencing it like:
 $htmlNewMsg = ${$html_msg->string_ref};

but still to no avail.  Any ideas?

--chad


On Wed, 2002-10-02 at 19:48, Earl Hood wrote:
> 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 = (
>     '/usr/bin/mhonarc',
>     '-single',
>     '-rcfile', '/etc/mimefilters',
>     '/tmp/mk_tmp001.msg'
>   );
> 
>   local(*MHONARC);
>   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 'mhamain.pl';
>   mhonarc::initialize();
> 
>   my $html_msg = IO::String->new;
>   my @mha_args = ('-quiet',
> 		  '-single',
> 		  '-rcfile', '/etc/mimefilters',
> 		  '-stdout', $html_msg,
> 		  '/tmp/mk_tmp001.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.
> 
> --ewh
> 
> ---------------------------------------------------------------------
> To sign-off this list, send email to majordomo@mhonarc.org with the
> message text UNSUBSCRIBE MHONARC-USERS
> 
> 


---------------------------------------------------------------------
To sign-off this list, send email to majordomo@mhonarc.org with the
message text UNSUBSCRIBE MHONARC-USERS


[Index of Archives]     [Bugtraq]     [Yosemite News]     [Mhonarc Home]