I'm experimenting a little with Automator at the moment and often get stuck with some pre-recorded automation running very slowly while the whole Mac (an 2010 iMac in my case) doesn't respond to any input - either by keyboard or mouse.

For now I connect via SSH from another machine and issue a killall Automator to get controls back.

Is there any solution available which enables me to halt / freeze a Mac and issue commands using a terminal?

  • 3
    I'm not certain what you want - you're already using the best solution I can see: SSH. It enables you to "issue commands using a terminal", including the halt command, shutdown. – Cajunluke Jul 17 '12 at 14:21
  • I'm looking for a way to do this directly on the affected machine... Automator grabs the keyboard and mouse and does not allow me to use a terminal while the automated task is running. – Daniel Bleisteiner Jul 17 '12 at 18:42

You could also run a "deadman's switch" app: have a script (maybe an Applescript) running when you start the Automator testing. After five minutes (or however long the Automator setup should take), it should display a dialog asking if you have control back this dialog would have a timeout (of 30 seconds or so), after which, it would try to kill the Automator process.

Example code:

delay 300

display dialog "Can you use the computer yet?" buttons {"Yes!", "No 😞"} default button 1 giving up after 30

set retval to (the result)

set gaveUp to (gave up of retval)
set theText to (button returned of retval)

repeat while gaveUp or theText is not "Yes!"
    set randomNumber to (random number from 1 to 65535)
    do shell script "kill -9 " & randomNumber

    display dialog "Can you use the computer yet?" buttons {"Yes!", "No 😞"} default button 1 giving up after 30

    set retval to (the result)

    set gaveUp to (gave up of retval)
    set theText to (button returned of retval)
end repeat

(Note that this code, instead of killing Automator, kills a random process. This is probably not a good idea, but I'm not sure exactly what you need to kill, and I thought it'd be fun. I've not actually tested that particular bit of code.)

| improve this answer | |
  • @bmike Can we get syntax coloring for Applescript here? Should I ask on Meta for that? – Cajunluke Jul 17 '12 at 21:05
  • That's something promising... I'll try this out. – Daniel Bleisteiner Jul 18 '12 at 4:48
  • It doesn't work this way... the script dialog times out and the AppleScript tells me that this happened... doesn't continue. But it gave me the idea to simply issue a killall Automator after some predefined timeout - no dialogs at all. Maybe that AppleScript can be improved... it leads to the solution... so accepted. Thanks! – Daniel Bleisteiner Jul 18 '12 at 6:22

It seems like you want the ability to enter commands using the mouse and keyboard when the mouse and keyboard are unavailable, which is sorta odd.

Anyway, I can think of a few ways to prod your computer into doing something without the mouse and keyboard.

  1. A Griffin PowerMate. Set it to open Terminal or run a script when you press the button.
  2. Do Something When. Set it to run a script when a specific USB flash drive (or similar) is inserted.
| improve this answer | |
  • These won't work if something is blocking The only way is ssh from a remote machine and that can fail as well – mmmmmm Jul 17 '12 at 20:39
  • @Mark Yes. The OP seems to be asking how to make the computer do something when it won't do anything, so any answer will have a certain level of nonsensicality. – Cajunluke Jul 17 '12 at 20:42
  • I want to gain control back... freeze other processes for a moment for being able to enter commands... then let go again. – Daniel Bleisteiner Jul 18 '12 at 4:47

Yes - the normal unix process control and shutdown commands allow you to reboot, shut down or otherwise suspend or kill arbitrary processes.

| improve this answer | |
  • I already know how to use a terminal... I'm looking for a way to open it if another process blocks normal access to keyboard and mouse. While the Automator runs the task I simply can't switch to a terminal the normal way. – Daniel Bleisteiner Jul 17 '12 at 18:45
  • Hmm - the "how can I xxx using a terminal" made it look like you wanted confirmation how to use terminal once ssh was done. If you don't have a log in already and finder/the event loop is already blocked, you are out of luck. You'll need ssh and have to hope sshd isn't blocked. – bmike Jul 17 '12 at 19:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .