So, for any of you who have had the misfortune to read my previous posts (the idiocy makes ones head swim) I have long had an issue where all of my folders that have scripts attached to them lose track of them when the computer gets shut down. I reformatted the hard drive a week and a half ago when I re-installed the OS but that did not help at all, the problem persists. HOWEVER I now know what fixes this issue just not what causes it!
I downloaded and use Maintenance 3.6 to run periodic maintenance on my Mac to keep it running smoothly and I noticed that after I run the ‘Clear Cache Files’ option and restart my Mac all of the folders with scripts attached are working again. I suppose I could keep performing this fix by hand but why when applescript will do it for me unattended? So using the scripts included in the program as a base I wrote the following but as you have guessed by this point it is not working
tell application "Terminal"
set tasks to {"sudo rm -r ~/Library/Caches/*;sudo rm -r /Library/Caches/*;sudo rm -r /System/Library/Caches/"} -- Set up a list of Unix tasks
do shell script tasks password "MYPASSWORD" with administrator privileges -- Run tasks with admin priveleges
end tell
tell application "Finder"
display dialog "Complete. Shutting down in 2 minutes" buttons {"Ok"} giving up after after 5
delay 120 -- Wait 2 minutes
tell application "System Events"
shut down -- Shut down the computer
end tell
end tell
The error I get is 'A privelege violation occurred." I had guessed the above would work but no so can anyone offer insight into what I am doing incorrectly? Just so you know, I am as well versed in Unix as I am in Urdu - not at all. Can I accomplish my goal using applescript instead?
Hi,
some notes:
¢ the do shell script command doesn’t need a Terminal tell block, even the tell block causes the error message, if administrator privileges is used.
¢ Apple recommends, not to use sudo in shell scripts in conjunction with administrator privileges.
¢ I assume, passing the shell script as a list won’t work
set tasks to "rm -r ~/Library/Caches/*;rm -r /Library/Caches/*;rm -r /System/Library/Caches/" -- Set up a list of Unix tasks
do shell script tasks password "MYPASSWORD" with administrator privileges -- Run tasks with admin priveleges
PS: personally I woudn’t delete caches in /Library and not at all in /System/Library
Thanks again Stefan and Bruce. I will TRY the script without the library and system cache deletions, but in the end I need to fix the problem with my folder scripts and if it means deleting system cache files I will have to do it. The automated folders are integral to my program.
I guess I will finally have to bite the bullet and buy a Unix book, any suggestions as to the best one for a beginner?
Have you tried this from another logon? I would suggest creating a new account and seeing if the problem exists there. If it doesn’t, perhaps you could move your files over to the new account? I have sometimes seen things get “horked up” in an account and no amount of tugging will get it to undo itself. Often, it is easier to move to a new user account and start with a clean slate.
More than likely, something has gotten corrupted in your prefs (where, I wouldn’t begin to guess). Rather than spend a lot of time, effort, and energy figuring these things out, it has been more profitable to me to just move my stuff to another account.
If the problem follows you, then you have a horse of another color, and we must look at what things you may be doing that is corrupting your privileges.
Brilliant suggestion Kevin! I must be getting old because it never even occurred to me to try that. I will set up a test logon in a few.
I’m embarrassed to admit how long it took for that idea to occur to me. I guess we get blinders on when we get involved in a “war” with the OS and often forget the first rule of computing – we’re the boss! LOL Instead, we set our jaw and get determined to “make it listen to us.” It’s so much easier to just whack it in the head and say, “I’m not playing your game!”
Well, I wanted to give it some time because I thought it was going to work, but no. Apparently the test logon suffers from the same malady of the primary one.
I guess what I will do is write an applescript to test a folder function at startup and if it fails run the cache cleaning script and restart the computer. It’s a bit of a hassle but it looks like the best solution I have.
-
Dumb question: have you tried repairing privileges and/or the hard drive using Disk Utils?
-
Not sure what hardware you’re running on, but make sure any firmware patches are installed OK, reinstall if necessary. Run the Hardware Utility if necessary.
-
Have you tried re-installing the OS? You can save your user files during the fresh install. Sounds to me like something is badly hosed in your OS or HD, and I would (if it were me) install a fresh copy of the os and move only my documents/pictures/etc. to a new user account (that way if you have hosed prefs they don’t follow you!).
Quite simply, this shouldn’t be happening and you shouldn’t have to put up with it. I strongly urge you to check hardware and reinstall OS before something more serious happens.
Once you reinstall, be VERY choosy about what extensions and system hacks you install. Some of the haxies are cute but not very useful and will hose the OS.
I reinstalled the OS over a wipe about two weeks ago and have all of the updated patches as of that date. When I reinstalled I didn’t move ANY of my preferences with me, just my personal files and I re-installed all of the applications from scratch from their disks.
I have tried repairing both the privileges and the hard drive.
As for hardware configuration a question arises - could the issue be caused because the folders in question are on an external USB 2.0 Seagate drive? The computer itself is a Mac Mini G4 with 1 gb ram, a 1.42 ghz PPC processor, and OS X 10.4.10.
I don’t think I have any hacks on this machine but I do have some freeware/shareware apps. and I’m running ClamXav anti virus just in case.
I know this is a screwed up situation and, yes, down the road it probably WILL bite me in the ass but short of re-installing the OS again then adding ONLY the absolutely necessary applications and testing… then adding another app and testing… then adding another app and testing… I just don’t have that kind of patience anymore. I could be testing the set up for weeks to identify the culprit.
Understood. More stupid questions (I’m just full of 'em!):
-
What format is the USB drive (Windows/Mac) and if Mac HFS, is it journaled? If the drive is formatted non-Mac (to be used also with another computer maybe) that might explain it.
-
Have you tried turning off permissions checking on the drive (Get Info, check “Ignore permissions on this drive”)?
My Drives format says Mac OS Extended (Journaled) and it is set to ‘ignore ownership on this volume’.
Don’t even give a second thought to asking me these questions, I just don’t want to be taking up YOUR time with stupid questions.