Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a simple AppleScript (packed as an app) that tells the Terminal to execute a couple of lines of code. Every so often -- about once every 7 to 10 days -- after a cold restart, the code has been "corrupted" somehow and the word "Terminal" in the Tell statement has been changed to "Applet" and the "do script" commands have been replaced by "«event coredosc»". I've been fixing this by just clicking edit on the error prompt and pasting in the right code for the app. Has anyone encountered this before? None of my other AppleScripts (also packaged as apps) that tell the Terminal to do things has this problem. Does anyone know how to fix this? I've also tried re-typing the app's sourcecode from scratch in a new AppleScript app and no dice.

I am using OS X 10.8.4. Here is the script:

set myProcessInfo to do shell script ("ps -x")

if myProcessInfo contains "httpd" and myProcessInfo contains "mysql" then
    do shell script "/Applications/MAMP/bin/"
    do shell script "/Applications/MAMP/bin/"
    tell application "Terminal"
            do script "/Applications/MAMP/bin/"
            do script "/Applications/MAMP/bin/ > /dev/null"
    end tell
    delay 10
    do shell script "killall Terminal"
end if
share|improve this question
Interesting. One thing I'd check when this happens is what the last modified time of the file in question is. Is it what you expect? – Michael Kjörling Aug 26 '13 at 12:38
Good suggestion! I hadn't thought of that. I'll check it next time it happens (which may not be for a few days since it happened this morning). – SteveoDevo Aug 26 '13 at 13:17
This has happened again. The file modified date on my app isn't changed. It reports the last modification date was August 26th. – SteveoDevo Sep 5 '13 at 12:31
The change looks so random and weird. I will question the integrity of the file allocation table of your partition. Could be your script just got some scrambled data from somewhere else? – Bichoy Sep 15 '13 at 6:07
@Bichoy I don't think that's very likely. «event coredosc» is something I could see showing up in AppleScript somehow (I've gotten errors about a cryptically-named «class» before). Steveo, depending on what your script does, you might be able to write a shell script to do it, instead of going through Terminal. If you need it to do other things as well, you might want to look into do shell script. It doesn't really answer your question, but it might be a good workaround. :) – Blacklight Shining Sep 15 '13 at 18:15
up vote 1 down vote accepted

I'm not sure how you would fix whatever's messing up the script, but you can work around it by using a shell script instead:


tempfile=$(mktemp /tmp/XXXXXXXXXX)
ps -x >$tempfile

if grep httpd $tempfile && grep mysql $tempfile
    /Applications/MAMP/bin/ >/dev/null

rm -f $tempfile

As I mentioned in the comments, if you have scripts for Apache and MySQL that exit successfully if the respective daemons are running and nonsuccessfully otherwise, you can use those instead of writing ps output to a temporary file and grepping it.

Alternately, you could use a modified version of your original AppleScript, using only do shell script and not tell application "Terminal" to do script:

set myProcessInfo to do shell script ("ps -x")

if myProcessInfo contains "httpd" and myProcessInfo contains "mysql" then
    do shell script "/Applications/MAMP/bin/"
    do shell script "/Applications/MAMP/bin/"
    do shell script "/Applications/MAMP/bin/"
    do shell script "/Applications/MAMP/bin/ > /dev/null"
end if
share|improve this answer
Thanks very much! – SteveoDevo Sep 20 '13 at 3:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .