Is there a way to speed this up?

I run this piece of script to get a password for a do script sudo “xxx” password myPW with administrator privileges:

tell application "Keychain Scripting"
	launch
	tell current keychain
		tell (some key whose name is "getASPasswd")
			set myPW to password
		end tell
	end tell
end tell

and it is tediously slow, taking 10 seconds or more to get the password. Is there another way to do it that’s faster?

You’re iterating through all the key types (generic, Internet & AppleShare) when I suspect you just want the generic key. This is to retrieve a password to a key you’ve set, right?If so, make sure the key that you’ve set is a generic key and then you can speed things up by asking specifically for the generic key:

If would be better if KeyChain scripting allowed you to cal a key by name specifically instead of using the whose name is test but that’s a rant for a different day…

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

True story, but because there are very few “generics” in my KeyChain, changing the type of that password to generic and then searching for that type only speeded it up immensely. Thanks.