Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Dangerous script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Dangerous script
Authored by: mzs on Sep 15, '05 11:29:58AM
I do not have 10.4 to try automator, but I think this script has a problem.

Run this command on your system:

osascript -e 'POSIX path of "; rm -rf $HOME"'
Does that give you a hint of what may be wrong with these lines inside 'Delete Files/main.applescript':


                        tell application "Finder"
                                set pospath to (POSIX path of f)
                                set p to ("\"" & pospath & "\"")
                        end tell
                        set cmd to rmcmd & " " & p
                        -- display alert "command: " & cmd
                        do shell script (cmd)
So what filename would you need to create in order to do the most damage then?

Maybe this would be a bit safer:


                        tell application "Finder"
                                set pospath to (quoted form of POSIX path of f)
                        end tell
                        set cmd to rmcmd & " --  " & p
                        -- display alert "command: " & cmd
                        do shell script (cmd)

Also note the use of the double dash -- in the command, read the man page for why, but the POSIX path probably means that will not be needed.

Another tip, you stated that this is released under the terms of the LGPL, yet there is no notice of this at the head of this applescript...

[ Reply to This | # ]

Dangerous script
Authored by: Anonymous on Sep 15, '05 03:06:12PM
Nicely spotted. One tiny error in your revised version:
 set cmd to rmcmd & " --  " & pospath
I'd say this is the whole reason the Trashcan concept exists - it's too dangerous to tell the system to force delete the value of a variable, precisely because it's a variable. Stick to the three keystrokes: command-backspace / command-shift-backspace / return. It's much faster than right-click submenu navigation anyway.

[ Reply to This | # ]