• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Keychain Scripting for Program Linking doesn't work! (sometimes}
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keychain Scripting for Program Linking doesn't work! (sometimes}


  • Subject: Re: Keychain Scripting for Program Linking doesn't work! (sometimes}
  • From: Sander Tekelenburg <email@hidden>
  • Date: Sun, 17 Mar 2002 19:28:03 +0100

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 22:52 +0100 UTC, on 16-03-2002, Harald E Brandt wrote:

> Consider the block:
> tell application "Keychain Scripting"
> unlock keychain "Link" with password "blabla"
> quit
> end tell
>
> Often, especially when I am not looking (i.e it runs scheduled unattended
> during night) it puts up an annoying dialog for name and password of a key
> for program linking rather than open all the keys directly as it should!
> This bad behaviour of keychain has plagued me for months!
>
> What is wrong??

Dunno. But wrapping problem code in try blocks will allow you to at least
catch the error number and message:

try
tell application "Keychain Scripting"
unlock keychain "Link" with password "blabla"
quit
end tell
on error m number n
display dialog n & return & return & (m as text)
end

In this case, since you only run into an error when your script runs
unattended, I would have it write the error to a file, instead of to a
dialog.

> The keychain in question holds keys to three machines - one key each for
> AppleShare via AppleTalk and one key each for Program Linking. Why does it
> *sometimes* put up the dialog for name and password, whereas it works
> perfectly when I run the script (applet) from the keyboard??
> It is as if there is a timing problem - something is sleepy during night
> and the key doesn't get open! Extremely annoying and I don't know what to
> do about it!?

If 'sleepiness' is the problem, you might want to toy with your Energy Saver
settings. Or you might need to insert a small delay in your script. Or you
may need to have your script retry until successful:

Have you tried putting it in a repeat, or an on idle block, to make it
attempt several times? Something like the below construction, which would try
a maximum of 5 times (or whatever number you assign to MaxRepeat), until
successful. Whether you just need 2, or 10 times you'll have to find out.

set theSuccess to true
set MaxRepeat to 5
repeat maxRepeat times
try
tell application "Keychain Scripting"
unlock keychain "Link" with password "blabla"
quit
end tell
on error number n
if n = x -- the error you are getting
set theSuccess to false
else
-- deal with other errors
end
end try
if theSuccess is true then -- Keychain is unlocked
exit repeat -- continue with other stuff
end if
end repeat
if theSuccess is false
-- deal with the fatal error
else
-- continue script
end

It's ugly, but if this makes your script reliable, it might be worth it.

Whether it makes more sense to use a repeat loop, or an on idle block will
depend on what else you're doing.


HTH


-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPJTgKusywKfXgqKdEQJ99gCfeOs73X5dXACHWIS0VzfICmrUb/QAoMIZ
oEDlYz7sc43+d51rR2cae7pu
=3wRn
-----END PGP SIGNATURE-----
--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Keychain Scripting for Program Linking doesn't work! (sometimes}
      • From: Harald E Brandt <email@hidden>
    • Re: Keychain Scripting for Program Linking doesn't work! (sometimes}
      • From: JollyRoger <email@hidden>
References: 
 >Keychain Scripting for Program Linking doesn't work! (sometimes} (From: Harald E Brandt <email@hidden>)

  • Prev by Date: Re: Working w Filemaker and the finder
  • Next by Date: Re: Booting from 9 into X
  • Previous by thread: Keychain Scripting for Program Linking doesn't work! (sometimes}
  • Next by thread: Re: Keychain Scripting for Program Linking doesn't work! (sometimes}
  • Index(es):
    • Date
    • Thread