Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Script the Login window through Apple Remote Desktop' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Script the Login window through Apple Remote Desktop
Authored by: markoneil on Feb 24, '10 11:55:39AM

I am in no way a programmer or a scripter but had an idea i was working on and was able to use some of this script to update one i was working on.

Basically i want to be able to select a bunch of mac machines using apple remote desktop and then graphically log into all of them, using different accounts.

There are plenty of scripts available that will allow you to log in multiple computers using the same account through ard, but this does not do what i need it to do.

In many of the environments i work in there are consecutive network accounts. Lab01 through Lab60 for example. I needed to be able to script each selected computer logging in to a different consecutive account and then select a particular workgroup.

I was able to put bits and pieces of script together to perform the log in portion, and then a second script to select the workgroup, but i really like how this particular script handles the username and password fields, making sure that a password is not accidentally inserted into the username field and therefor making it visible for students or other users to see. Anyway here are the two scripts put together in what i am sure is horrible code. I would love to be able to create one script out of the two but need to make sure that the first portion waits until the workgroup selection window is active before proceeding with the second portion of the script. I could use a simple delay but depending on the environment, some computers may present this window quicker than others and i dont want to delay the quicker computers by having a delay time that will accomodate the slower computers.

Anyway here they are.

display dialog "This script will graphically login to a group of selected computers using unique consecutive usernames and their passwords. (lab01, lab02, lab03, etc...)" with title "Multi User GUI Login"
set num to 1 as text
set dialog_1 to display dialog "Please enter username prefix: (lab, fsa, test, etc...)" default answer "lab"
set the user_name to the text returned of dialog_1
set dialog_2 to display dialog "Please enter the password for these users: " default answer "12345" with hidden answer
set the pass_word to the text returned of dialog_2
tell application "Remote Desktop"
set theComputers to the selection
repeat with x in theComputers
set thescript1 to "echo -n \"a\" > /private/var/db/.AccessibilityAPIEnabled"
set thetask1 to make new send unix command task with properties {name:"Enable accessibility", script:thescript1, showing output:false, user:"root"}
execute thetask1 on x
delay 1
if length of num < 2 then
set num to "0" & num as text
end if
set thescript2 to "osascript -e 'tell application \"System Events\"' -e 'tell process \"SecurityAgent\" to set value of text field 1 of group 1 of window 1 to \"" & user_name & num & "\"' -e 'tell process \"SecurityAgent\" to set value of text field 2 of group 1 of window 1 to \"" & pass_word & "\"' -e 'click button \"Log in\" of window 1 of application process \"SecurityAgent\"' -e 'end tell'"
set thetask2 to make new send unix command task with properties {name:"Multigui Login", script:thescript2, showing output:false, user:"root"}
execute thetask2 on x
set num to num + 1 as text
end repeat
end tell


here is the second script

display dialog "This script will select and login to the workgroup specified on all selected computers in the following steps. " with title "Workgroup Selector"
set dialog_1 to display dialog "Please enter first few letters of desired workgroup: " default answer "student"
set the work_group to the text returned of dialog_1
tell application "Remote Desktop"
set theComputers to the selection
repeat with x in theComputers
set thescript2 to "osascript -e 'tell application \"System Events\"' -e 'keystroke \"" & work_group & "\"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'"
set thetask2 to make new send unix command task with properties {name:"Select workgroup", script:thescript2, showing output:false, user:"root"}
execute thetask2 on x
end repeat
end tell

Any input or help would be appreciated, In no way do i take credit for this script, just the idea.




[ Reply to This | # ]
Script the Login window through Apple Remote Desktop
Authored by: Swooper on May 03, '10 12:11:30PM

I must be missing something. None of these scripts have any effect on my local computers.

During summer upgrades, we frequently need to log into a large number of computers simultaneously. Similar scripts worked in years past but now, nothing.

Do I need to turn on this "access enabled" thing previously mentioned? I could use some help with that.



[ Reply to This | # ]
Script the Login window through Apple Remote Desktop
Authored by: DudeWheresMyCar on Sep 10, '12 09:07:57PM

markoneil,
I need to do exactly what you're describing here, but I'm not sure how to get it running.

Could you give me some quick basics on where/how to save that script and then how to run it from the "Remote Desktop" program?

FYI, we're running 10.4 through 10.6.8 from a 10.7 server.

New wrinkle: I've got more than one lab computer prefix (e.g. emac##, imac##, etc.); guess I'll have to rename them, but that's fine with me.



[ Reply to This | # ]