MACSCRPT Archives

October 2007

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Stockly, Ed" <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Thu, 4 Oct 2007 10:33:30 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (88 lines)
Thanks Mark, 

That helps.  
> with timeout of 15* seconds
> get application "Safari"
> on error
> KillSafari()
> end

I tried this on several web pages that trigger crashes and it worked on
some, but on others, it didn't work. Even though the dock indicated the
application was not responding and it's name was in red in the Force Quit
window, it still returned a value on the get application command.

But, this worked:

try
    with timeout of 15 seconds
        tell application "Safari"
            zoomed of window 1
         end tell
    end timeout
on error
    KillSafari()
end try

on KillSafari()
    do shell script "killall Safari"

end KillSafari

It's possible that any number of commands could work rather than zoomed of
window 1, I'll try a few and see. Maybe a command that doesn't require an
open window would be more versatile.


I'll give the shutdown script a go later on, but this has been a big help,
thanks again!

Ed

On 10/3/07 7:00 PM, "MACSCRPT automatic digest system"  wrote:

> Re: Crashes and Freezes
> 
> On Oct 3, 2007, at 3:55 PM, Stockly, Ed wrote:
> 
>> I'm working on a script that controls Safari, Firefox and/or iCab.
>> 
>> When any of these browsers display pages that have some specific ads
>> and
>> javascript they will crash or cause the Finder to crash.
>> 
>> My script can detect when the browser or the finder have
>> unexpectedly quit
>> and can clear the dialog and relaunch.
>> 
>> What I can't do is figure out how to determine if the browser has
>> frozen and
>> is not responding, and how to force quit the browser.
>> 
> Try this
> 
> with timeout of 15* seconds
> get application "Safari"
> on error
> KillSafari()
> end
> 
> do shell script "killall Safari"
> 
>> I'm also looking for a way to force restart the mac, without
>> worrying about
>> saving or logging off nicely.
>> 
> 
> do shell script "shutdown -r now" password "password" with
> administrator privileges
> 
>> These scripts are running on mac minis who's only functon in life is
>> to
>> display web pages.
>> 
>> Any suggestions?
>> 
>> ES
>> 

ATOM RSS1 RSS2