Re: running applscripts from a cron file
Re: running applscripts from a cron file
- Subject: Re: running applscripts from a cron file
- From: "Donald S. Hall" <email@hidden>
- Date: Thu, 10 Jan 2002 22:36:33 -0700
Ben,
This came up about 2 months ago. The messages below may indicate your
problem. I publish a shareware program called Script Timer that will do what
you want. Since it runs in your user process group, it doesn't try to do any
messaging across a group boundary.
HTH,
Don
>
I have the latest version of Mac OS X. I am trying to get cron to run a
>
script that loads a web page. The script works fine. I cant seem to get
>
this to be reliable. I have classic open and I rely on Ido script
>
scheduler. That works without a problem. Any suggestions? Here is the
>
line in my crontab.
>
>
30 * * * * osascript
>
/Users/bcompton/Documents/Scripts/Iwon-Icab
From a previous thread on the AppleScript Users' Mailing List:
----------------------------------------------------------------------------
>
> On Monday, November 12, 2001, at 09:54 PM, Gary Beberman wrote:
>
>
>
>> I am trying to make a script run automatically in OS X 10.1 using
>
>> crontab. Whenever I do, the script starts. And I immediately get an
>
>> error dialog telling me:
>
>>
>
>> "Application isn't running"
>
>>
>
>> The strange thing is that the application is running. Even this simple
>
>> script trips
>
>>
>
>> tell application "Finder"
>
>> open file "OS X:Users:Shared:somefile"
>
>> end tell
>
>>
>
>> And the stranger thing is that I can run the script from within
>
>> Terminal just fine. If, from the comand line, I call the script the
>
>> same way I call it in crontab, it runs perfectly.
>
>>
>
>> What's different in crontab? What can I do about it to get my
>
>> Applescripts to run?
>
>
>
> You're seeing a security "feature." It has to do with Mach messages,
>
> which form the guts of Apple Events on Mac OS X. For security reasons,
>
> processes in Mach are segregated into "process groups", and a process in
>
> one group is not allowed to send messages to a process in a different
>
> group. Because cron gets launched at boot time, it's in root's process
>
> group, while every application launched by your login (including the
>
> Finder) is in your process group. Therefore, a script run by cron can't
>
> talk to any application that you launched.
>
>
>
> There's something of a bug in AppleScript here, too -- at its level, it
>
> can see the application, so it tells the Apple Event Manager to send it
>
> a message, and you get a surprising error.
>
>
>
> It's not clear what the truly correct solution is here -- there are
>
> valid security reasons for keeping the process group restrictions in
>
> place. In the meantime, what can you do? Well, scripting additions
>
> should still work, so you can use those. cron unfortunately makes sure
>
> that only one instance of cron is ever running at once, so you can't
>
> launch your own personal cron, though if you're feeling extra studly,
>
> you could get the source for cron (it is open, after all) and modify it
>
> appropriately.
>
>
>
>
>
> --Chris Nebel
>
> AppleScript Engineering
--
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
http://www.theboss.net/appsmore
email@hidden