![]() I prefer using the security command so I’ll include this method in my AppleScript as opposed to Usable Keychain Scripting though the latter will function just as well. Set thePassword to do shell script ("security find-generic-password -wl \"MAMP\"")ĪppleScript to obtain user name and password using the security command in Terminal Set theUserName to do shell script ("security find-generic-password -l \"MAMP\" | grep \"acct\" | cut -c 19-99 | sed 's/\"//g'") # get the user name and password using the security Terminal command The same can be achieved using the security command in Terminal: Repeat with x from 1 to (length of theKeyList)ĪppleScript to obtain user name and password using Usable Keychain Scripting Set theKeyList to every generic item of current keychain whose name is "MAMP" Tell application "Usable Keychain Scripting" # get the user name and password using Usable Keychain Scripting Using Usable Keychain Scripting the following AppleScript will grab the Account Name and Password for the keychain item named MAMP and assign each to a variable: The two alternatives methods I mentioned earlier for accessing the keychain using AppleScript are Red Sweater’s Usable Keychain Scripting and the security command in Terminal. Enter the Account Name and Password you use to login into your computer and click Add. Open Keychain Access.app in the /Applications/Utilities folder:Īdding a new keychain item in Keychain AccessĮnter the Keychain Item Name. We’ll see two alternative methods later, but first we need to create a new item in our keychain. Prior to Mac OS X Lion it could be found in /System/Library/ScriptingAdditions/. Unfortunately, as of Mac OS X Lion the Keychain Scripting.app is no longer included. To overcome this security issue a new item can be added to the users keychain and made available to the AppleScript using Keychain Scripting. Saving this AppleScript as an Application and adding it to the Login Items will work but it has one major problem the PASSWORD and USERNAME are stored in plain text.ĭo shell script "/Applications/MAMP/bin/startApache.sh
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |