Login while running post image script?

abenedict
New Contributor II

I was wondering if anyone knew of a way for me to login to an account via my
postimage script because I need to lock the screen until all of the
postimage installs/configurations are complete. I can't seem to find any
commands that will allow me to do what I am looking for. Thanks!
--
Alan Benedict
?
Macintosh Technician
The Integer Group
http://www.integer.com

7 REPLIES 7

tlarkin
Honored Contributor

I have this in one of my post image scripts because the add wireless
package we use wants a user logged in for some reason, however, I code
mine a bit different. Since you can invoke shell/Applescript from one
another it is easier to just maintain the Apple or shell script in it's
entirety and plug it in accordingly. This is of course my opinion.

This is how I do it.

#!/bin/bash

bunch of shell script commands...

/usr/bin/osascript < tell application "System Events" keystroke "$admin1_short" keystroke return delay 3.0 keystroke "$admin1_passwd" delay 3.0 keystroke tab keystroke return keystroke return end tell
EndOfMyScript

Now at the top of my scripts I hard code the values for local admin
accounts, therefore, when I want to edit them, I simply edit the the
variables and be done with it. This way my image is also still 100%
pristine. Since you are evoking Apple Script from shell, it will still
abide by all your shell variables. I hard code in values for
admin1_short (which is the short name for local admin acocunt) and the
password for admin1 so I never have to edit the script beyond changing
the variables.

Also, AppleScript combined with shell script is pretty much the best
thing ever, and pretty robust and powerful.

-Tom

dhowell
Contributor

this script I use in ard

osascript -e 'tell application "System Events" to keystroke "username"';
osascript -e 'tell application "System Events" to keystroke tab';
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'

D. Trey Howell ACMT, ACHDS, CCA
trey.howell at austinisd.org
Desktop Engineering
twitter @aisdmacgeek

Some people have told me they don’t think a fat penguin really embodies the race of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They’d be a lot more careful about what t
hey say if they had.

– Linus Torvalds, announcing Linux v2.0

abenedict
New Contributor II

Good stuff, one question, Casper lays down a local account for management
(and I don't hide it) so the login screen shows me this account and "other". How would I script selecting other and then logging in?

Thanks
--
Alan Benedict
?
Macintosh Technician
The Integer Group
http://www.integer.com

On Fri, Jun 4, 2010 at 2:18 PM, Thomas Larkin <tlarki at kckps.org> wrote:

I have this in one of my post image scripts because the add wireless package we use wants a user logged in for some reason, however, I code mine a bit different. Since you can invoke shell/Applescript from one another it is easier to just maintain the Apple or shell script in it's entirety and plug it in accordingly. This is of course my opinion. This is how I do it. #!/bin/bash bunch of shell script commands... /usr/bin/osascript <<EndOfMyScript tell application "System Events" keystroke "$admin1_short" keystroke return delay 3.0 keystroke "$admin1_passwd" delay 3.0 keystroke tab keystroke return keystroke return end tell EndOfMyScript Now at the top of my scripts I hard code the values for local admin accounts, therefore, when I want to edit them, I simply edit the the variables and be done with it. This way my image is also still 100% pristine. Since you are evoking Apple Script from shell, it will still abide by all your shell variables. I hard code in values for admin1_short (which is the short name for local admin acocunt) and the password for admin1 so I never have to edit the script beyond changing the variables. Also, AppleScript combined with shell script is pretty much the best thing ever, and pretty robust and powerful. -Tom >>> 06/04/10 12:26 PM >>> this script I use in ard osascript -e 'tell application "System Events" to keystroke "username"'; osascript -e 'tell application "System Events" to keystroke tab'; 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' D. Trey Howell ACMT, ACHDS, CCA trey.howell at austinisd.org Desktop Engineering twitter @aisdmacgeek Some people have told me they don’t think a fat penguin really embodies the

race of Linux, which just tells me they have never seen a angry penguin

charging at them in excess of 100mph. They’d be a lot more careful about what t

hey say if they had.

tlarkin
Honored Contributor

I would add a command in your post image script to disable the username
list and pcitures and just do the username and password fields by
modifying the loginwindow.plist found in the CoreServies folder.

That way you wouldn't have to deal with that and it would hide the list
of users from the login window.

-Tom

tlarkin
Honored Contributor

Actually, my bad....

You need to edit the property list in /Library, example

sudo defaults write /Library/Preferences/com.apple.loginwindow
Hide500Users -bool TRUE

and to hide other

sudo defaults write /Library/Preferences/com.apple.loginwindow
SHOWOTHERUSERS_MANAGED -bool FALSE

That way it will not display a list of user names at the login window

sean
Valued Contributor

Alan,

I can't say I've looked at these scripts in any depth, but you can start typing any name at the login screen and then hit return.

So if you want user Other, you should be able to change the top of the script to

/usr/bin/osascript <<EndOfMyScript tell application "System Events" keystroke "o" keystroke return delay 3.0

As long as your local admin account doesn't start with an 'o'

Sean

tlarkin
Honored Contributor

If you look at my post image script, the script creates the user
accounts, so when you hardcode the variable for admin1_short the Apple
script will log in using that account information