Applescript quirk


If you are trying to write an Applescript that uses the useful do shell script command to run something, and you encounter the error: An error of type 1 has occurred. you might be using too many pipes. I was trying to use a command with two pipes and it continued to give me that error. I even tried to put the multi-pipe command into a bash script and run it that way, but it still caused a problem. I eventually rewrote the command to use awk instead of grep and that allowed me to use only one pipe.

As a side note, if you want to determine programmatically whether or not the screen saver is running in OS X, you can use this command:

ps -auxww | awk '(/ScreenSaverEngine/) && !(/awk/)' -

If it returns something then it is running, otherwise not. It can be used in an Applescript that you might have either running as a cron or looping with the =on idle= construct. I’m using it to set my iChat status to Away when I turn on my screen saver — which is something I do when I’m not at my desk. Combine that with the script using my network addresses to determine my status message and I don’t have to worry about keeping iChat current. If anyone wants this script let me know.

Written by Colin Bate