Name
Keychain Scripting
Synopsis
As I mentioned before, a keychain
is a password file or database that is stored in encrypted form in
startup disk:System Folder:Preferences:Keychains.
The scripting of keychains, which store important
passwords for entry to systems such as local networks, is
accomplished through the Keychain Scripting software that is included
with the scripting additions in the startup disk:System
Folder:Scripting Additions folder. Figure 12-1 shows the checkbox that allows you to add a
passphrase for an encrypted file to a keychain. You script the
Keychain Scripting application just as you would target any other
program, such as by enclosing Keychain Scripting commands in
tell
statements.
Syntax
tell app "Keychain Scripting" get current keychain -- get default keychain end tell
Dictionary commands
- count keychains or keys
This command counts the number of keychains the computer system has or the number of keys in a keychain. You can have more than one keychain; for example, I have a separate keychain just for linking with other Macs on my Ethernet. One keychain is always the default or active one and receives any new keys you create (see the
current keychain
property of the keychainapplication
class). If you want to count just the number of keychains, use this code:tell app "Keychain Scripting" to count keychains
This code gets a count of keys within a keychain and returns an
integer
:tell application "Keychain Scripting" tell keychain "MyPasses" to count keys ...
Get AppleScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.