AppleScript to Bash

Any ideas on converting an applescript into bash? Simple method to get rid of delimiters?

More info?

What kind of script? What kind of delimiters? GUI or not?

The applescript I've built allows me to disable (within OS 10.6) the automatic login within security of system preferences. I'd like to covert this script into bash to run with a different utility. Below is an example of what I've been able to get the applescript to do:

-- Enabling �Disable automatic login� checkbox.

set uiScript to "click checkbox \"Disable automatic login\" of group 1 of tab group 1 of window \"Security\" of application process \"System Preferences\""

run script "tell application \"System Events\"
" & uiScript & "
end tell"

You're not going to be able to convert that into bash, applescript is completely 100% indelibly proprietary. You can't program GUI events in a bash script... You'll have to figure out where and how the settings are actually stored and modify that instead.

Google is your friend:

loginoptions 1.0 software Mac OS X - VersionTracker

I have not tried this, but it reportedly will allow login options to be set from the command line.

Thanks Corona688. I'll check it out drewk, thanks for the tip.

You can invoke shell from Apple Script and vice version

for apple script to invoke the shell:

do shell script "/bin/echo Hello World"

or

invoke AppleScript from the shell

/usr/bin/osascript -e 'tell app "System Events" to display dialog "Hello World" '

However, you can most likely do this from the shell regardless, so no need to even do that. I think modifying the plist file will suffice:

defaults write com.apple.mcx.DisableAutoLoginClient -bool true

I am using open directory so my settings may differ, but the file this pulls from is the com.apple.LoginWindow.plist file, so you may want to edit that file and test it out before you push it out.

This looks like the best way to invoke the applescripts I'm building, tlarkin. I can keep the original applescripts, build a shell script to run before the applescripts in order to invoke the commands to execute properly. The key for me is making sure that these scripts are copied to the user template so that any user who authenticates into the machine sees the same customizations. This is the goal I'm trying to achieve.

Well, if you are using Open Directory you can use MCX to set those, if not you can also modify the user template in /System/Library/User Template so that every time a user account gets created it will pull those preferences from the template.

Any other scripts you want to run you can use launchd to automate them.

Yeah, like here is an example of a post image script I am using to force an admin log in after image, since some of the stuff I install post imaging requires that a user be logged in.

/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

The $admin1 variables are the variables I hard code at the beginning of my shell scripts to create the local administration accounts. So, when I update the script to change passwords or change accounts, it will still use whatever I hard code at the top.

This is really cool because now after I image a Mac, the post image script automates everything for me and I can sit back and relax and let it do it's job for me. The alternative is manually logging into 6,000 Macbooks, no thanks.:eek: