Re: Setting password of a keychain key
Re: Setting password of a keychain key
- Subject: Re: Setting password of a keychain key
- From: kai <email@hidden>
- Date: Tue, 28 Mar 2006 20:55:47 +0100
On 28 Mar 2006, at 14:02, Stephen Jonke wrote:
I am having trouble scripting Keychain Scripting. The following
works fine:
tell application "Keychain Scripting"
tell keychain 1
unlock
set theKey to (first key whose name is "Some Key")
set password of (first key of keychain 1 whose name is "HST
VPN") to "SomePassword"
end tell
end tell
However, the following does not work:
tell application "Keychain Scripting"
tell keychain 1
unlock
set theKey to (first key whose name is "Some Key")
set thePassword to text returned of (display dialog "Enter new
password" default answer "" with hidden answer)
set password of (first key of keychain 1 whose name is "HST
VPN") to (thePassword as string)
end tell
end tell
It gives an error at the "set password" line. I've tried casting
the entered password to "Unicode text", to "International text" and
to "string", as well as not casting. Nothing seems to work. Has
anyone gotten this type of thing to work?
Keychain Scripting evidently requires plain text, Steve - which helps
to explain why your first version works and your second doesn't. (The
text returned from display dialog is Unicode text. Even after the
coercion to string, it still contains some embedded style data that
causes Keychain Scripting to choke.)
Try changing the line that sets the variable 'thePassword' to:
---------------------
set {text:thePassword} to text returned of (display dialog "Enter new
password" default answer "" with hidden answer) as string
---------------------
(Incidentally, I'd be tempted to place this line before the
application tell block, rather than inside it.)
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden