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

[MacPerl] MPW crashes when running an AppleScript from a Perl script



In order to be able to use command line arguments with Perl I've installed MPW
and everything works except that it crashes 8-)

The first time I run the script, the files are modified and a message is created
in Mailsmith. BUT the second time I run it MPW crashes. I tried it three times
and the first time it didn't even drop into Macsbug, it just frooze my Mac. The
second time I got this message from Macsbug:

Bus Error at 0015DE96 'PACK 0008 0002 AevtMgr'+00746
while reading long word from 72342650 in User data space

The third time I got:

Illegal Instruction at 0016B86B

If comment the AppleScript lines it seems possible to run this script several
times.

Anybody who can tell me what I'm doing wrong? (script follows)


                jem
                
---

Perl -Sx "{0}" {"Parameters"}; Exit {Status}
#!perl 
require MacPerl;
require HUMlabServicePack;


if( $#ARGV != 5){
    print "Usage: am 2000-04-07 10:00 12:00 Glasburen \"Donald Duck\"
\"Ankeborgs årsmöte\"\n";
    exit;
}

my $theDate         = $ARGV[0];
my $theStartTime    = $ARGV[1];
my $theStopTime     = $ARGV[2];
my $thePart         = $ARGV[3];
my $thePerson       = $ARGV[4];
my $theTitle        = $ARGV[5];

my @dateParts = split /-/, $theDate;
my $theLine =
"$dateParts[0]\t$dateParts[1]\t$dateParts[2]\t$theStartTime\t$theStopTime\t$thePart\t$thePerson\t$theTitle";
my $theYearDir = $ENV{"HUMlabData"} . $dateParts[0] . ":";
my $theMonthFile;
my @theDates;
my @allDates;

if( -e $theYearDir ){
    # print "Katalogen finns\n";
} else {
    mkdir $theYearDir,0777 || die "Kunde inte skapa en katalog för året\n$!\n";
}

$theMonthFile = $theYearDir . $dateParts[1];

if(-e $theMonthFile ){
    # Läs in filen
    open(DATAFILE,"<$theMonthFile") || die "Kunde inte inte öppna filen
<$theMonthFile> för läsning\n$!\n";
    @theDates = <DATAFILE>;
    close(DATAFILE);
    # Lägg till det nya datumet och sortera
    chop @theDates;
    @allDates = (@theDates, $theLine);
    @theDates = sort @allDates;
} else {
    # Om filen inte fanns så finns det bara ett datum
    @theDates = ($theLine);
}

# Öppna filen för skrivning

open(DATAFILE,">$theMonthFile") || die "Kunde inte öppna file <$theMonthFile>
för skrivning\n$!\n";
print DATAFILE join("\n",@theDates);
print DATAFILE "\n";
close(DATAFILE);

updateHTMLPages($dateParts[0],$dateParts[1]);

$mailMessage =  "Detta är en automatisk bekräftelse av din bokning av
HUMlab\n\n" .
                "Följande uppgifter har noterats" .
                "\n        Datum : " . $theDate .
                "\n          Tid : " . $theStartTime . "-" . $theStopTime  .
                "\nKontaktperson : " . $thePerson .
                "\nDel av HUMlab : " . $thePart .
                "\n        Syfte : " . $theTitle .
                "\n\nOm något av detta är felaktigt eller det är något du undrar
över kontaktar " .
                "du Jan Erik Moström, jem\@humlab.umu.se\n\n";

$theScript = <<EOS;
tell application "Mailsmith 1.1"
    make new message window
    set subject of window 1 to "HUMlab: bokningsbekräftelse"
    set contents of window 1 to "$mailMessage"
    set sending account of window 1 to "HUMlab" 
end tell
EOS

MacPerl::DoAppleScript($theScript);
--
Jan Erik Moström                                  mailto:jem@mostrom.pp.se
Free Elektron                           http://www.mostrom.pp.se/folk/jem/

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org