Don't Use Manual Procedures.
A shell script or batch file will execute the same instructions, in the same order, time after time.
The most common way I use scripting is to use Ant to create build scripts for my Java projects. Any IDE will do a lot of the things an Ant script typically does, but an Ant script is far more portable and can be scheduled to execute without a GUI (e.g., automated nightly builds).
After using Ant, I looked at languages like Ruby and Groovy. In the beginning I was mostly interested in them from a bit of an acedemic perspective (i.e., dynamic languages vs strongly typed languages) but I've also used them for automating the occasional non-visual tasks.
Lately I've come to realize that there are also plenty of tasks that could benefit from scripting GUI applications. Afterall there is plenty of functionality in GUI apps that I may want to leverage in a routine way. Enter Applescript. Somewhat surprisingly, Mac OS X's user interface and most Mac applications are pervasively scriptable. In fact just drop into XCode to build a native Mac OS X Cocoa application and your application will be Applescriptable out of the box. You can call command line scripts from Applescripts and you can call Applescripts from command line scripts. The best of both worlds.
Applescript first shipped with Mac System 7.5 in 1994. Having done some HyperCard development back in University in the late 80's I can say that Applescript seems to share a syntactical heritage with Hypertalk. For you non-Apple folks that means that Applescript attempts to be English like in its syntax in an effort to improve readability. So for example a simple script to get the Mac to move a file around might look like this:
move file "Bob" of startup disk to folder "Joe" of startup disk
I'm just starting to get into Applescript and while it's unfortunately one of those technologies that's platform dependent, I figure I should probably get somewhat comfortable with it since it's everywhere in my current OS of choice. I'll write up another entry if I discover anything particularly interesting.
[Update] Here's an article espousing the goodness of Scripting/Dynamic Languages.
No comments:
Post a Comment