I have two very simple OSA scripts to allow logon and logoff of computers in a lab environment. These scripts work flawlessly in Snow Leopard when pushed via ARD, interactively within an ssh session, but they fail on machines running Lion.
Stripped down to its essentials, the logout script looks like this:
osascript -e 'tell application "System Events" to log out'
The login script is directly based on this. A stripped-down version that exhibits the problem is:
osascript -e 'tell application "System Events" to keystroke "frontend"'
Because these scripts work fine interactively, and because they worked fine in all modes in Snow Leopard, I think something must have changed in osascript, but I don't know what, and the error messages aren't very descriptive. Any suggestions would be welcome.
Try escaping the quotes.
So:
osascript -e 'tell application "System Events" to log out'
becomes:
osascript -e 'tell application \"System Events\" to log out'
And
osascript -e 'tell application "System Events" to keystroke "frontend"'
becomes:
osascript -e 'tell application \"System Events\" to keystroke \"frontend\"'
Give that a go and tell us what happens.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With