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


Click here to return to the 'a better way' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
a better way
Authored by: mkoz on Apr 12, '02 10:49:53AM
from the "Standard Additions Dictionary":
do shell script: execute a shell script or command
	do shell script  plain text  -- the command or shell script to 
		execute.  Examples are ‘ls' or ‘/bin/ps -auxwww'
		[administrator privileges  boolean]  -- execute the command 
			as the administrator
		[password  plain text]  -- use this administrator password 
			to avoid a password dialog
	[Result:   plain text]  -- the command output

if you notice you can leave out the password and you will be prompted for an administrator password.

so with that information we can make some slight changes to the script, with no stored password.

display dialog "Empty Trash as root?" buttons ¬
	{"Cancel", "TRASH"} default button "TRASH" with icon note

set the user_choice to the button returned of the result

if the user_choice is "Trash" then
	display dialog "ARE YOU SURE?" buttons {"NO", "YES"} ¬
		default button "NO" with icon note
	set the user_choice to the button returned of the result
end if

if the user_choice is "Yes" then
	do shell script ¬
		"rm -rf /.Trashes/*  ~/.Trashes/*  ~/.Trash/*" ¬
		with administrator privileges
	--"/Volumes/*/.Trashes/*"
end if


[ Reply to This | # ]
a better way
Authored by: dev909 on Apr 12, '02 11:39:44AM

thanks mkoz!
I already changed that but I didn't post...



[ Reply to This | # ]