Posted on 09-18-2009 09:44 AM
Hey All,
I am sure this is a simple thing, but let's say I have autologin configured
for a user account. The autologin works at a reboot like it should.
Let's say the account does a standard logout so now it returns to a login
screen.
Is there a way to invoke the system to autologin again without having to
reboot from the command line or by starting/stopping process(es)?
Thanks,
Craig E
Posted on 09-18-2009 09:51 AM
I'm not sure you'd want to do that. What if you need to log in with an admin account or something? The second you logged out after login, it would log you back in again. Am I missing something?
---
Jared F. Nichols
Desktop Engineer, Infrastructure & Operations
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436
Posted on 09-18-2009 10:21 AM
Yes you are. =) HOW DARE YOU QUESTION ME!
Just kidding...
No you are right about that potential problem. Once this account does what it needs to do I fully intend to delete the user account, disable auto logon, and restore my loginwindow preferences to what they should be. =)
Want to trigger a policy by a specific username login. I do it now with a reboot after I apply my autologin packs and I am trying to get away from the reboot because it’s causing some issues on occasion.
Pretty sure the new jamfHelper is doing this for CS installs at FirstRun. Adds the user account and somehow is making it login...
Craig E
Posted on 09-18-2009 10:30 AM
How about a five-minute interval launchd .plist that checks for whether or
not a user is logged in? You can probably grep 'last console' for 'still
logged in'.
If the script returns 'false' because it can't find 'still logged in' then
you can reboot the system and let your autologin work as designed.
--
bill
William M. Smith, Technical Analyst
MCS IT
Merrill Communications, LLC
(651) 632-1492
Posted on 09-18-2009 10:37 AM
I'm also curious as to why you'd want this, however, I have done some pretty strange things in the past... ;)
Anyhow, here's how I think I'd do it:
osascript -e 'tell application "System Events" to delay 10';
osascript -e 'tell application "System Events" to keystroke
"usernamehere"';
osascript -e 'tell application "System Events" to delay 3';
osascript -e 'tell application "System Events" to keystroke return';
osascript -e 'tell application "System Events" to delay 3';
osascript -e 'tell application "System Events" to keystroke
"userpasswordhere"';
osascript -e 'tell application "System Events" to delay 3';
osascript -e 'tell application "System Events" to keystroke return';
Depending on how your login window is configured, and how long you'd like it to wait before logging in as the user.
Hope this helps!
Cheers,
Kerry
BASD Net Admin
Posted on 09-18-2009 10:40 AM
Thanks Kerry.
Would the first return be a tab rather to move down a field?
Craig E
Posted on 09-18-2009 10:42 AM
No problem, I'm pretty sure either would work. I use this with ARD's "send unix" command when I want to log a bunch of computers in at once for any reason. It's GREAT for load testing, etc.
Luck! ;)
Kerry
Posted on 09-18-2009 10:56 AM
The tech before me at a site used this with ARD and Send Unix command to login as a local user. it seems to work better for me, and we use the name and password login window.
sudo osascript -e 'tell application "system events" to tell process "SecurityAgent" to keystroke "student password "'
I think the "student" is the shortname and "pwassword " is the password, " " and " " must be Tab and Return. less to type I guess.
Nathaniel Lindley
++++++++++
Information Technology
Saint Paul Public Schools
Saint Paul, Minnesota
nathaniel.lindley at spps.org
phone: 651-248-6861
Posted on 09-21-2009 05:54 AM
Thanks Nathaniel, that is a great script and works wonderfully on
newer machines.
I would be remiss if I failed to mention that I attempted to use a
script very similar to this one a couple years ago but was running
into problems with it skipping letters in the password field, putting
the user and pass all in the "user" field, or sometimes it would not
work at all on our older G3 machines with 10.3.9. That's why I
resorted to adding the "delays"; it seems it allowed the machine
enough time to catch up with the script... apparently. Maybe it was
just ARD?
Anyhow, if you've got nothing older than a G4, you'll probably be fine with the one-liner, otherwise, if you're using ARD, you could use the "template" feature to prevent having to type it or paste it again and again.
Hoping to prevent headaches, ;)
Kerry