NERD! Homepage

Abort an Automator workflow

I wanted to abort an OSX Automator workflow if there’s no internet connection. That function does not exist. It can be done by inserting the action Run Applescript though:

try
do shell script "curl www.apple.com"
on error
do shell script "killall name-of-this-script"
end try

Fill in the name of your Automator application and if there’s an error the script will terminate itself. This way you can build multiple checks. For instance I have another check that stops the automator workflow if a certain disk is not mounted. And suddenly Automator becomes a handy tool.

david Hund | | #

So what if you DO have Internet access?!
Will you download the apple.com website besides running your script :-P?

Am I missing something? How about just a simple PING command?

Dave

Vasilis | | #

A simple PING command would do, I guess. I haven’t tested it though. In my case I access a script on my server which makes a backup of my databases. I just replaced it with a domain that’s always up.

david Hund | | #

Yeah, but CURL will download the site, right?

Vasilis | | #

It shows the HTML when I type that command in the terminal. It’s not physically downloading apple’s website to my computer.

Delicious (Dutch)