Click to See Complete Forum and Search --> : 2 questions: script + rm -d doesn't work


x
03-13-2001, 04:18 AM
1) Typing "cd /etc" moves me to /etc. Putting this line in a script doesn't work - it just feeds another command line.
Script is executable, located in /bin. I've tried !#/bin/bash as well as /bin/tcsh & /bin/sh, no difference. (Default shell = bash.)

2) rm -dr should delete directories recursively, but it doesn't. I get the following:

[root@Edgar applnk]# rm -dr ./Applications
rm: move directory "./Applications"? y
rm: unable to remove "./Applications": is a directory
[root@Edgar applnk]#

rm -d or rm-dr as well as -D gives the same. (Directory Application contain only 2 files, I've tried on directory trees too.)

P.S. While I'm asking, just 2 more small questions:
Sometimes I read about "the sticky bit": "Check if you have set the sticky bit.." etc, but what is this sticky bit?

People sometime use "LOL". This is short for something I guess, but, English not beeing my native language, I haven't been able to figure out what?

Choozo
03-13-2001, 05:23 AM
For the 'rm' command, try 'rm -rf <directory>'

The 'sticky bit' is the 's' bit or suid (Set User ID) which means that a user runs this program as the owner of that program (usually root). If you do a 'ls -l' in /usr/bin you will find a lot of files that have permissions like this:

-rwsr-xr-x 1 root root

Permissions are divided into r(read) w(write) x(execute) for owner|group|world. Looking at the owner permission above, you will see that the execute (x) for 'owner' is replaced with an 's'. This means that 'joe user' can run this program as root.

Finally, acronyms are used a lot on the net. LOL is a acronym for Laughing Out Loud.

Cheers! :)

[ 13 March 2001: Message edited by: Choozo ]

x
03-13-2001, 06:25 AM
Of course - that's the sticky bit! I know about permissions, have seen the 's' but just didn't get the connection. Thanks!
And thanks for LOL, too - I understand most of the acronyms but not all!
Cheers! :)

I tried -rf too, have tried all combination of the 3 letters r/d/f, same result. (Actually, the message is "unable to unlink..", I translated from Swedish in my question.)
It's the same in RedHat & Slackware.
Could it be because it's on a FAT16-partition?

Choozo
03-13-2001, 07:58 AM
Originally posted by x:
Could it be because it's on a FAT16-partition?

That could possibly be the case. Check the man pages for mount and fstab and see how the FAT16 partition should be mounted in /etc/fstab to allow write (in effect delete also). (You may also have to make sure you don't have umask=nnn for those partitions in the /etc/fstab).

[ 13 March 2001: Message edited by: Choozo ]

x
03-14-2001, 04:12 AM
you
No, that's not it.
I can't delete any directory, no matter on what partition it is. I tried to do it as root but it didn't help.
I can however delete the directories with Midnight Commander! :confused: :confused:
That solves the problem, but I still would like to know why 'rm -d' doesn't work?
Anybody tried it, can you do it? :confused:

Choozo
03-14-2001, 05:14 AM
I've never tried this since Linux is the only OS on my box.
I'll just step off this thread at this point, and hope someone else have an answer for you?

Good Luck :)

Lorithar
03-14-2001, 12:55 PM
*ummms*

after rereading the man page for rm, I question your use of rm -d. This 'unlinks' the directory to which you point it, and likely should NOT be used on a directory that is a) not on an e2fs disk, b) contains files, The reasons noted are that it unlinks the directory from the tree, and strands the inodes of files in that directory. (basically you need to fsck the disk afterwards to get the inodes back).

I suggest using rmdir, or rm -rf [path]/filename (or * if you wish to remove all files in the dir)
Further on a FAT16, the umask in fstab WILL play havoc with what you can and can't do to the files on the disk, even as root. Midnight commander can see the logic required to get around those limitations. (you end up needing to set an appropriate umask first)

If the disk is FAT16, how is it mounted?


As for the script question, how is this script running, who is running it, and what shell are you using to run the script.

(see the first line, #!bin/(xx)
the xx or xxx would be the shell you are using to run the script it)
I don't think I've seen that 'fail' but the possibilities are a) the script has insufficient rights to go there, the user has insufficient rights to go there, or the prompt is not being modified and you are actually there...

{swats self -- thats in the original post ...sorry ... ]

[ 14 March 2001: Message edited by: Lorithar ]

x
03-15-2001, 04:41 AM
Thanks, Lorithar!
I was just going to ask why it said "can't unlink.."
Let me just add that rm -d doesn't work on an empty ext2 -directory either...

About the script... Excuse me, forgive me, I,m banging my head into the wall now... :rolleyes:
Yes, I have read a lot about shells & scripts, and should know how they work:
The script works, of course, but doesn't take me to the directory. For this I'll use an alias instead.
Thanks again, guys! :p