Shell and Automator


I’ve been doing far too much “punditry” the past few weeks here. So I wanted to give a few tips.

To start let me give a great way to keep infrequently used shell scripts. If you are like me you have some shell commands you run only occasionally. For instance when I am trying to debug a network I often use nmap (installed via MacPorts). However because I do it so infrequently I have to remember the arguments to the command and then how I mapped the NAT. (Some networks use 10.0.0.x while others use 192.168.1.x and others 192.168.0.x) So I put the following as a service in Automator.

nmap -F 192.168.1.0-255 | mate

This makes it easy to find the machine I need to ssh into. (I make several automator actions for each network) I can also see, from a security point of view, what services are up (and what services shouldn’t be up).

If you don’t have TextMate installed (mate is the shell command for TextMate) then you can simply add the “New TextEdit Document” action after the “Run Shell Script” action.

Now I just showed this with the nmap command but I do this with a whole slew of commands I infrequently run. It saves me the constant googling I used to do in order to run these commands. For instance I have a bunch of scripts that do various parsing of email that I have setup as Automator services. (I just wish that in the Services menu it’d separate out global services from app specific services)

Automator1.jpg

Automator has definitely become the feature of Snow Leopard I cared the least for at the time and which is now amazingly helpful for me. Automator went from somewhat pointless to invaluable. If you haven’t been using it much you really ought to. I just wish it had a way to turn the clipboard into a temporary file so I could act on that. (For graphics I nab from Bing or Google Images – right now I save them in the Finder and then run an Automator script to resize them for blogging)

Related posts:

  1. Applescript Shell
  2. Python and Automator
  3. Tips for Writing Scripts
  4. Automator Question
  5. TextMate & Python
  6. Man Pages in Preview and Textmate
  7. Script Storage
  8. Managing Services in SL
  1. #1 by Jeremy on 2010/07/18 - 2:48 pm

    I’m trying to create a loopback alias when I login. I don’t want terminal to open and the script only needs to run once. The command is ‘sudo ifconfig lo0 127.0.0.2 alias up’.

    So far I’ve tried 1) saving Automator’s “run shell script” as an application for adding to ‘login items’ and 2) creating a text file for the launchagents folder…which I’m pretty sure is the wrong path to walk down anyway.

    I enjoyed your post and I believe I’m close. Thanks in advance for your insight.

  2. #2 by Clark on 2010/07/19 - 6:20 pm

    Look at doing a Launch Agent for this. See the docs for launchctl.

    Also see this post of mine

(will not be published)