Applescripting Seti@ home

Aug 13, '01 06:53:43PM

Contributed by: robg

[Submitted by phlbbrtn on Saturday]

In this hint I will show how to control the Darwin (command line) version of Seti@home using AppleScript. For this there are these ingredients:

Read the rest to find out how to control Seti@home with AppleScript.

When I first started using OS X one of the first things I did was to get the graphical Seti@home client and install it. It was veeeeeery slow in its beta version. I hear it's a little faster now.

But I ditched that version and got ahold of the Darwin command-line version. It works much faster, even if the learning curve to use it is steeper. The rest of this assumes you already have the Darwin Seti client on your computer.

The Mac OS X Power Additions package is some tools to integrate the Unix shell with AppleScript. In the package is the file called "OSX PowerAddOns Lite.osax" which is placed in the /Library/ScriptingAdditions folder.

Shell Scripts I have in my /Users "Home" directory a directory called "bin" which I have included in my command path in .cshrc. In ~/bin are the following three scripts.

1) Start Seti@home: "seti"

#!/bin/sh
cd /Users/phil/Setiathome/
setiathome -nice 20 >/dev/console
exit
2) Check Seti's progress: "prog"
#!/bin/sh
cat ~/Setiathome/state.sah | grep prog
3) Quit Seti@home: "kset"
#!/bin/sh
kill `ps aux | grep setiathome | grep -v grep | awk '{print $2}'`
exit 0
Create these scripts in a plain text editor and give them executable permissions (chmod 755) and place them in your command path. (FYI this is Unix Programming Lite. Mastery of the shell.)

Next, once you have verified that your commands work, open the ScriptEditor in /Applications/AppleScript. In the new script window type:
Shell "~/bin/seti"
Save the script as a "Compiled Script" in your ~/Library/Scripts folder. Name it what you want. Start a new script and type:
Shell "~/bin/prog"
Same as before. Save as compiled script and give it a name. Next script (quitting the process):
Shell "~/bin/kset"
Lastly in /Applications/AppleScript, there is a Script Runner app. Open this one up and click on the symbol in the little box and you will have a menu of all your compiled scripts.

Be careful of how you use scripting like this. Careless typing mistakes can cause damage to your filesystem. Use at your own risk, but it works quite nicely if you do everything right. Here's a screenshot showing everything working.

Comments (1)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20010813185343633