Re: system rm from Big Cat
Re: system rm from Big Cat
- Subject: Re: system rm from Big Cat
- From: Michael Grant <email@hidden>
- Date: Mon, 18 Nov 2002 21:05:45 -0600
On 11/18/02 7:27 PM, "Alex Robinson" <email@hidden> wrote:
>
This works for me:
>
>
>>>>
>
on main(filelist)
>
>
repeat with aFile in filelist
>
set aFile to aFile as alias
>
set aPath to posixPath aFile
>
set cmdStr to "/bin/rm -R " & "\"" & aPath & "\""
>
do shell script cmdStr with administrator privileges
>
end repeat
>
>
do shell script "sudo -k"
>
>
end main
>
<<<<
That does work, thanks!--but it asks for the password repeatedly when
deleting more than one file. A little more editing gives this:
on main(filelist)
set thePaths to ""
try
repeat with aFile in filelist
set aFile to aFile as alias
set aPath to posixPath aFile
set thePaths to thePaths & "\"" & aPath & "\" "
end repeat
set cmdStr to "sudo /bin/rm -R " & thePaths
do shell script cmdStr with administrator privileges
on error number errNo
system "sudo -k"
error number errNo
end try
-- invalidate sudo password immediately
system "sudo -k"
end main
And now we've got the answer next time someone complains that they can't get
rid of a file!
Michael
--
"But I also made it clear to [Vladimir Putin] that it's important to think
beyond the old days of when we had the concept that if we blew each other
up, the world would be safe."
? George W. Bush, Washington, D.C., May 1, 2001
_______________________________________________
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.