I work at a High School and we need to set up labs for testing. We have a local user account that we need to log in and some testing software to launch. We typically do this to make it easy for the testing coordinators; they just come in and the software is already up. Since I do not want to type the username/password manually on each computer, I want to use a script or command to do this.
In 10.6 I just ran these simple AppleScript commands from ARD or saved it as a script and ran it via Remote:
osascript -e 'tell application "system events" to keystroke "username"'
osascript -e 'tell application "system events" to delay 0.5'
osascript -e 'tell application "system events" to keystroke return'
osascript -e 'tell application "system events" to delay 0.5'
osascript -e 'tell application "system events" to keystroke "password"'
osascript -e 'tell application "system events" to delay 0.5'
osascript -e 'tell application "system events" to keystroke return'
In 10.7, I noticed this no longer worked. So here is what I came up with:
touch /private/var/db/.AccessibilityAPIEnabled
osascript -e <<EOF 'tell application "System Events"
tell process "SecurityAgent"
set value of text field 1 of window "Login" to "testing"
set value of text field 2 of window "Login" to "testing"
end tell
tell application "system events" to keystroke return
tell application "system events" to keystroke return
end tell'
EOF
I am not sure if anyone else would want this or not, but I thought I would just throw it out there.
I have found it useful for setting an entire lab up for testing. Once the user is logged in, I send another command to launch the testing software. Now, when the students show up, they just choose their test and off they go.