Script It: Do More

| Comments

First of all, why this post? because today after a stressful meeting I opened Google and saw the Doodle of the day. Then I said to myself “let’s play to this track and field of Google” but after few tries I tough that probably I could hack it somehow. Then I opened AppleScript and generated some loops and voila! This has kept me thinking that sometimes we do not automate machines enough.

It really amazes people when they move to OSX and they find out (or are showed by someone) the automation that a normal user can do. The things a user can do with automator tasks and smart folders are still very complicated or much less friendly in other platforms.

-But what about me?
-Well, you know as well as I do that these things are not going to work for you, but with your technical skills and background (I would think that if you ever read this blog is because you have some) should be doing this on a regular basis.

What I mean is that spending a little bit more time in making the machine solve its problems automatically, by following the orders you put together on a script will save you a lot of time in the medium/long term.

Let me put you some examples, you could create an installer that puts a .mobileconfig profile on the computers, sends you an email from a post flight script with the result of the installation and the details of the machine and asks to reboot. There you have it. A semi-automated way of putting computers into the right computer groups in profile manager.

Another example, you have more than one AD/OD server and you want to ease the typing of your technicians. Then you create an AppleScript with a “choose from list” and a “do shell script”

I can think of many different cases

  • Read property files and modify their values if not equal to XYZ
  • Assign specific DeployStudio workflow depending on computer model
  • Ping a list of machines and write to output files
  • List local users and email you the results
  • Create folders
  • An applescript that installs a Munki and once finished asks a technician for the preferences values

This kinds of solutions, when you take enough time to make them, can even become a final or close to final solution to a problem you had. For instance I created an AppleScript to notify AD users when they reach a percentage of their assigned Xsan shared folder. Sure it took me a couple of days to do it but is a functionality that was not there before.

Yes I have mentioned Applescript several times during the posts. I know but the thing is that even after so many years existing you can do and combine many amazing things. Just the ability to show some options to the user and execute shell scripts on the background gives you a lot of power, and is that easy!

Hopefully some day soon I’d be able to say that I am as effective on Objective-C or more.

A recommendation for anyone willing to start with it would be the AppleScript 1-2-3 book.

Some of the initial code to break the Google record:

delay 1
tell application "Safari" to activate
delay 0.5
tell application "System Events"
repeat with i from 1 to 400
keystroke (ASCII character 29) -- Right
keystroke (ASCII character 28) -- Left
end repeat
end tell