Re: Newbie Questions
Re: Newbie Questions
- Subject: Re: Newbie Questions
- From: Axel Luttgens <email@hidden>
- Date: Thu, 09 Oct 2003 14:32:01 +0200
Ivan Nuqez wrote:
Hello guys,
I just have a quick question. I am running OS 9.2.2 and
MacManager 2.2. I want to run a script to delete a folder
on the local volume. I want to run the script at
shutdown. I have tried to run the script from the
'Shutdown Items' Folder in the SystemFolder, but I get a
problem. The problem is that when you the user does not
log in and only shuts the computer down, the script
interrupts the shutting down process and there for the
computer stops working completely. Otherwise, if the user
has logged in and then shuts down the computer there is no
problem.
Just to be sure, this is how I understand your description:
You have put a script, containing a 'tell application "Finder" '
statement, into the client computer's Shutdown Items folder; that script
has to delete some folder on shutdown.
When a logged user asks to shutdown the computer, your script executes
correctly.
When the computer is on the login screen (no logged user logged) and one
clicks the Shutdown button, the computer hangs. [1]
I found an article discribing my problem and telling what
not to do to fix the problem.
http://www.applescriptsourcebook.com/tips/gotchas/shutdownscripts.html
It essencially says: To avoid this problem, ensure scripts
in the Shutdown Items folder do not contain tell
application block / activate commands.
If my above understanding is correct, the explanation might be somewhat
different.
With the client computer being at the login screen, there is just one
running process ("Connection"). So, a script being executed in such a
computer state and containing a ' tell application "Finder" ' statement
will just fail, as there is no Finder at all.
Moreover, since Connection doesn't really provide a user interaction
context, your script is attempting to display an error message but
miserably fails at that, and is very likely collapsing the whole system
as well... [2]
On the other hand, when a user is logged in, the Finder is running and
may thus act as a target for your script. [3]
I would first try by enclosing the WHOLE script within a 'try ... end
try ' construct, so as to avoid spurious error messages. [4]
If this works, and should you need more control upon what's happening,
you could then refine your script by providing more granularity to the
error trapping.
If it doesn't work (if the client computer still hangs when no user is
logged), then yes, your hypothesis could be the right one.
But even then, some "vanilla" workarounds should still be available.
Could you give a first try, and let me know the results?
My Main question is how can I write a script to delete a
folder without the 'Tell application block / activate
commands' ??????
With Apple's standard configuration, you need the Finder to delete an
item, hence your ' tell ' statement.
Now, unless I'm missing something, an ' activate ' statement shouldn't
be needed at all.
On the other hand, should you really need to avoid the Finder then, yes,
you would have to use a third-party tool (for example, Harv suggested "
Jon's Comands OSAX" in his reply).
HTH,
Axel
[1] It also seems that you are only considering MMgr users with Finder
access, as the whole thing might be different with users having
Restricted or Panels access.
[2] That is, I really don't remember if your script would in that
context really go furher than just erroring and, for example, try to
launch the Finder. And alas, I don't have the opportunity to perform
some tests here, as my servers are in production 24/24.
[3] Note that in that case, a ' tell application ' statement doesn't
launch an application in the course of shutdown process; it just targets
an already running application.
[4] This could even suffice for your precise purpose, as you seem to be
happy with the results when a user is logged in (if no user has logged
in, no folder to delete should have been created anyway, shouldn't it?).
_______________________________________________
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.