I have a script that prompts for user name and password and mounts multiple NT volumes. This didn’t work with OS9 but now does again with 9.0.4. I’m updating it to support the keychain and here’s my problem.
Working in OS9, I can “tell application ‘Keychain Scripting…’” with no problem. However, when I try to run the script on a OS8.6 box, it starts out by asking where “Keychain Scripting” is - even though it never executes the “tell” statements. The script does check the OS version before trying to access “Keychain Scripting”.
So, the question is, how do I code a “tell application” statement and run the script when the application may or may not exist.
Thanks Kevin
Thanks for the response. I would have prefered keeping it in one script, but your idea sounds like a good solution.
: It occurs to me I didn’t understand your question
: properly. A way to not attempt a “tell
: keychain” would be to store the script as two
: files. The first checks if keychain is in the control
: panels folder, and if it is, loads then runs the
: script with the keychain tell block.
:"how do I code a “tell
: application” statement and run the script when
: the application may or may not exist.
"One solution:
Ask if the file exists within a finder tell block. That is:
tell app "Finder"
if (exists item "Keychain Access" in control panels folder") then
do stuff
end
end
You might be able to adapt the “double tell” trick or use what are called “raw events” (enclosed in chevrons). Here is quote from the double tell page
This brings us to the second method of telling an application by variable, where we dispense with the double-tell and use raw events. Here is the same script with the double-tell removed. Now the script will run and get the results in all circumstances without the risk of a dialog appearing asking for an application. Of course Eudora must be running for it to work at all, but that is easily guaranteed by launching it by creator type in the first place.
set creaType to "CSOm"
tell app "Finder" to the first process whose ¬
creator type is (creaType as «class type»)
set appEudora to the result as «class psn »
tell appEudora to ¬
get «class euNa» of first «class eNck» in «class eNfl»
0
→ “MACSCRPT@LISTSERV.DARTMOUTH.EDU”***
The key phrase being; “Now the script will run and get the results in all circumstances without the risk of a dialog appearing asking for an application.”
Sounds like that’s what I want - figuring it out will be the hard part. I’ve done a second script to work around the problem but I’ll have to look at this as a better solution.
Thanks Kevin