A little history:
I have been having a problem with my folder actions in that they would often disappear (become unlinked?) when I powered my Mac down. I have since discovered that it is only the folder actions that reside on my external HD (USB 2.0 Seagate) that disappear and that the folder actions on my Macintosh HD are all intact - odd that. Unfortunately all of my FTP folders are on the external drive because it has a far greater capacity (500 gb) than the main (80gb) so it isn’t at all feasible to just up and move the FTP folders onto the main disk to fix this problem, plus this is a Mini so upgrading the HD is probably not possible either.
So I wrote an apple script to turn into an app that runs every time the computer boots up just to test a folder, whose only reason to exist is to delete any file placed inside it, to make sure it is working properly OR it is supposed to delete all the files from the “Macintosh HD:Library:Caches:” folder and reboot, for some reason this does fix the problem and all of the folders on the Seagate drive will work properly - until the NEXT time.
The problem now is Unix, or rather my incomplete understanding of it. Please see the script below:
delay 30 -- Wait for drives to finish mounting
set lScriptsFolder to ((path to applications folder) & "Design-Mo-Tron:Components:Scripts:") as Unicode text
set lTapperFolder to ("Macintosh HD:Volumes:ESD MAC:Tapper:") as Unicode text -- Path to a folder on the external drive
set lTapText to (lTapperFolder & "Tapped.txt") as Unicode text
tell application "Finder" to make new file at lTapperFolder with properties {kind:"Plain text document", name:"Tapped.txt"} -- Must create empty text file
delay 5 -- Wait for folder action
tell application "System Events" to if exists lTapText then -- Problem with the folder scripts again
try
tell application "Finder" to delete lTapText -- Remove it because the folder actions didn't
do shell script "sudo rm -r /Library/Caches/*" with administrator privileges -- Run tasks with admin priveleges
display dialog "Deletion of cache files completed." & return & "Restarting in 30 Seconds" buttons {"Ok"} giving up after 5 with icon caution
delay 25 -- Wait 30 seconds total
tell application "System Events" to restart -- Restart the computer
on error number -1728 -- Can't get file
quit application "Restart - Auto"
end try
else
ignoring application responses
tell application "Design-Mo-Tron" to activate -- Launch the Queue Manager
end ignoring
end if
The line do shell script “sudo rm -r /Library/Caches/*” with administrator privileges or even do shell script “sudo rm -r /Library/Caches/*” password “MYPASSWORD” with administrator privileges results in an ‘Access violation occurred’ error. How much more access is there than SUDO?