Shell script to empty trash? Applescript maybe?


What I'm wanting is to create a shell script that'll empty the trash of my regular user account as root. I don't know if this is possible using sudo in the terminal or not. I don't want to put in the password if there's anyway around it. If I do have to put in the pass I'd like it to be in an aqua window. Hince my question about applescripting.

Does anybody know if this is possible?:confused:
sudo rm -rf ~[username]/.Trash/*

(replacing [username] with your real username) should do it, if the problem is permissions on files in the trash.

The other problem might be that the files would be locked - this seems more likely; if you haven't got the privileges to delete a file, I'm not sure you would have the privs to move it to the trash in the first place. Check out the man page for SetFile, that should do the trick in that case.

Personally I'd rather put my password in a terminal window, there at least I know what is being done and I have more control, but that's just me... Apple's .pkg installers are notorious for trashing things if they're not done just so, and if the files they expect to find are not just where they expect them
Awesome, thanks a bunch.
Is there anyway to delete locked files from the trash?
I thought there may have been a way to remove them but I guess I could be mistaken.

What I'm looking to create is a file that I can double click on and run (or run using a simple command through term) to empty my trash with root permissions.
I'm looking for a solution to a similar problem, as I'm also an AppleScript newbie. I want to run a command in Terminal using sudo, and I can get as far as getting the script to do the sudo command, but then it prompts me for my pasword. How Can I automate this reply as well? I've tried looking in the Terminal dictionary, but there seems to be only the 'do script with command' command.
OK, I can't delete a series of folders.
I've tried everything I can find.

The problem seems to be that the bottommost
nested folder has two "." files (like "." and "..")

I can't seem to rename or delete one of
the "." files.

anyone seen this one?
Type which rm in the Terminal. It should say /bin/rm. If not, then you probably installed a newer version of the the file utilities (as was mentioned on this site, MacOS X Hints, and Resexcellence, among other places). Unfortunately, the rm command has a bug such that it can't delete folders with too many files in it. To fix this, if, for example, the which rm gave back /usr/local/bin/rm, type

sudo mv /usr/local/bin/rm /usr/local/bin/rm.bad

give it your administrative password, and then type
for it to start using the proper rm

Of course, if it's not it, then we'll have to find something else...
naw, I know unix...

I've reposted this under "Mac OSX (10.x & newer)"

This is what I get when I "ll"
[localhost:Behavior Demo/Library/Media] xegan% ll
total 0
drwxr-xr-x 4 xegan unknown 264 Feb 8 19:27 .
drwxr-xr-x 4 xegan unknown 264 Feb 8 19:27 .
drwxr-xr-x 3 xegan unknown 58 Feb 8 19:19 ..
[localhost:Behavior Demo/Library/Media] xegan%

Thanks Red, but my "rm" is workin just fine : )
And the folder isn't locked as far as I can tell...

anyone got any guesses now?
What does the output of ls -laF look like (this'll append certain characters to the end of file/dir names to represent their type). Let's see if there's anything weird after the dot in there.

Also, when was the last time you checked your disk (via fsck or Disk First Aid)?
sudo rm -rf ~[username]/.Trash/*

why can't I get that command to work? it says "sudo: no match" in fact, most of the commands I see used in this forum or at don't work for one reason or another... usually sudo no match or what have you.... i'm so confused....