Applescript Applet : log or output to file when the script crash

Is there a way to log or write information to a file when my applescript program crashes? I’ve compiled my script into an application. The script opens an Excel file, does some processing to the Excel file then saves the Excel file. Sometimes the program crashes because it looses connection to Excel because Excel crashes then my Applescript program crashes and it’s stuck. Is there a way to make my Applescript write to a file like “program crashed” whenever it crashes? That way I can have another script that checks the log file every few minutes. If it determines that the main Applescript program has crashed I can restart it automatically.

Thanks
Ez

Hi martinezezmeral,

Excel shouldn’t be crashing in the first place (I think), but what do you mean by your AppleScript app crashing?

gl,
kel

Unfortunately, Excel does crash. I export my script as an application, we’ll call it myscrip.app. when myscrip.app is running, it processes a bunch of Excel files and once in awhile Excel crashes and when Excel crashes, my program, myscrip.app also terminates with a number of different type of error messages… I think it all depends on when Excel crashes. For example, if it’s trying to paste data to Excel or open an Excel file, etc… When myscrip.app crashes I get a dialog box that gives some error message, prompts me to click ok before it the program exits. So I’m wondering if there is a way to handle write some type of log to a file to so I know that the program has crashed. Right now the way I’m checking for myscrip.app crashing is if it is still running but the process utilization is less than or 0.1 percent of CPU usage. This is not always accurate and it takes longer to detect this sometimes. If I can write to a log file whenever it crashes I can have another program that periodically checks every 30 seconds to restart myscrip.app and continue with processing the Excel files.

Thanks,
EZ

I have written a zillion posts here about logging with the help of a logit handler, and watch the output in Console.app, and you can even configure Console.app so it pops up a preconfigured window for a logfile, instantaneously when something is written to that logfile.

If you search for “log”, “logging”, or “logit” in this forum, you should be able to find something.