----- Original Message ----- 
From: "Steve Rothman" <[EMAIL PROTECTED]>

| My problem is that I can't figure out how to automate it, and I'll 
| need to do it once a day.  On a unix system one would just type 
| something on the shell like:
| 
|        #  mhonarc  mailboxname  -outdir  :outputpath  -rcfile 
| resourcefile.rsc  -add
| 
| And so it would be really easy to make a shellscript to do this.
| 
| I've tried writing an AppleScript, and I can launch MacPerl and 
| MHonArc from AppleScript just fine, but I can't figure out how to 
| simulate typing in the command line.


I know nothing of mhonarc but suppose I wanted to read my eudora In mailbox and do 
something with it, then I'd do something like the script below.  You can run this just 
as it is and see the result, but the essential thing is that you send an Apple Event 
to MacPerl with a «class list» as the parameter:

             .... do script {varScript, arg1, arg2, argn....}

 (arg1, arg2, argn....) become perl's @ARGV


This script reads the first chunk characters of the mailbox, performs one or two 
useless transformations and prints it to a file in your tempdir. The 'mode batch' 
option prints also to your AS result window and this result can then be used further 
by your AS script if need be.



        tell app "Eudora" to set inbox to "" & (get file of mailbox 1)
        set chunk to 10000
        set cmd to {} & "
                $fout = $ENV{TMPDIR}.'temp.out';
                open FOUT, qq~>$fout~ or die $!;
                $mailbox = $ARGV[0];
                $chunk = $ARGV[1];
                open MAILBOX, $mailbox;
                read MAILBOX, $_, $chunk;
                s~^From \\?.+~------------~mg;
                s~^Re[\\w-]+:.+\\n~~img;
                s~^X-.+\\n~~img;
                print FOUT;
                print;
                "
        set end of cmd to inbox
        set end of cmd to chunk
        tell app "MacPerl" to Do Script cmd mode Batch

JD



Reply via email to