Re: call mhonarc from script

1999-10-12 22:07:09
On October 12, 1999 at 19:27, zheng wang wrote:

Is it possible to get some example scripts that call mhonarc? I am trying
to automatically convert the mail from petidomo into html file.

Will you being calling MHonArc within Perl programs?  Is so, you
can invoke MHonArc directly without using system().  For example,
look at the source code for "mhonarc":

    unshift(@INC, 'lib');       # Should I leave this line in?

    require '' || die qq/ERROR: Unable to require ""\n/;
    mhonarc::process_input() ? exit(0) : exit($mhonarc::CODE);

In sum, to call MHonArc with Perl programs, you do the following
to initialize the MHonArc library:

    require '';

Note, you may need set @INC properly if is not in perl's
default search path.

Once that is done, you can invoke mhonarc::process_input() to
process data.  You can pass arguments to mhonarc::process_input()
as you would pass arguments on the command-line.  For example:

                '-rcfile', '/path/to/resource/file.mrc',

The difference is that the arguments are passed as a Perl list.
This is actually more secure than using system() since no shell
interpretation is done (unless of cource you invoke system with
a list argument).

mhonarc::process_input() will return a true value if everything went
ok.  Else, it returns a false value, and exit code can be
retrieved with $mhonarc::CODE;

This embedded Perl approach allows to call MHonArc on multiple
archives (*in sequence*) without the overhead of forking off a
process each time.

For more complex examples of the MHonArc API, see the various mha-*
utility programs.

Someday I will get around to documenting the API.


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