The following from the script is copied to my script library ...
- If you need to use a password in a script, you can use a keychain to store the password and get a script for it. Thus, your password is protected because you do not need to store passwords in clear text in a script.
- Create a password item - open the Keychain Access application and select the keychain in the left column. Then click File> Create Password Entry ..., enter a name, enter the account in the account and enter the password. Highlight it in the password list and get information about it. Under the Attributes button, enter its type as a shared key. This was chosen because there are few of them, and the search is much faster.
- NOTE. In 10.7 apple, keychain scripts are removed, and so we now use the security command line tool
getPW("name of keychain item") on getPW(keychainItemName) do shell script "security 2>&1 >/dev/null find-generic-password -gl " & quoted form of keychainItemName & " | awk '{print $2}'" return (text 2 thru -2 of result) end getPW
source share