Created
October 25, 2012 17:57
-
-
Save rmanly/3954329 to your computer and use it in GitHub Desktop.
ARD login to lab with different accounts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
computer_name=$(scutil --get ComputerName) | |
login() { | |
/usr/bin/osascript << EOF | |
tell application "System Events" | |
keystroke "${1}" | |
keystroke return | |
delay 1 | |
keystroke "${2}" | |
keystroke return | |
end tell | |
EOF | |
} | |
# just add more case statements as needed with the | |
# computername as the choice and the username and password | |
case "${computer_name}" in | |
lab_imac-01) | |
login user1 "pass1" | |
;; | |
lab_imac-02) | |
login user2 "pass2" | |
;; | |
*) | |
echo "ERROR: computername not found in case!" | |
exit 1 | |
;; | |
esac |
Of course! I have done this before myself when passing a variable from a bash script to an AppleScript Window!
Well done. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works - it expands the bash variables in the script before executing it. And allows you to basically embed the script itself instead of piece it together with multiple lines or multiple -e arguments to osascript.
login() {
exec osascript <<EOF
tell application "System Events"
keystroke "${1}"
keystroke return
delay 1
keystroke "${2}"
keystroke return
end tell
EOF
}