Why are simple osascript commands not working in OS X Lion?

I have two very simple OSA scripts to allow logging in and logging out in a lab environment. These scripts work flawlessly in Snow Leopard when pressed through ARD, interactively in an ssh session, but they do not work on machines that Lion runs on.

Having split up to its core, the logout script looks like this:

osascript -e 'tell the System Events program to exit the system

  • WORKS when launched directly from the interactive shell on the machine
  • WORKS when pressed from ARD
  • FAILS with "runtime error: out variable not defined. (-2753)" when starting from ssh session
  • WORKS when the script is compiled into .scpt, then run from ssh (for example, "/ usr / bin / osacript logout.scpt")

The script input directly depends on this. An outdated version that detects a problem:

osascript -e 'tell the System Events program to the frontend key

  • WORKS when launched directly from an interactive session
  • WORKS when pressed from ARD
  • FAILS with runtime error: An error of type -10810 has occurred. (-10810) when starting from ssh
  • WORKS when executed as compiled scpt and executed from ssh

Since these scripts work fine in interactive mode, and because they worked perfectly in all modes in Snow Leopard, I think something should have changed in osascript, but I do not know that the error messages are not very descriptive either. Any suggestions are welcome.

+4
source share
1 answer

Try following quotes.

So: osascript -e 'tell application "System Events" to log out' will look like this: osascript -e 'tell application \"System Events\" to log out'

And osascript -e 'tell application "System Events" to keystroke "frontend"' will look like this: osascript -e 'tell application \"System Events\" to keystroke \"frontend\"'

Give it back and let us know what happens.

0
source

All Articles