Bash - command is executing but do nothing without complaining


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash - command is executing but do nothing without complaining
# 1  
Old 10-26-2012
Bash - command is executing but do nothing without complaining

Hello.
This part of script do nothing but no complain.
Here the directory content :
Quote:
/root
/root/.ssh
/root/.ssh/config ( owner root mode 700 )
/root/.ssh/list_user ( owner root mode 644 )
The script run by root
Code:
cd /root
CMD="rmdir -p -v --ignore-fail-on-non-empty  .ssh"
echo $CMD
$CMD

The ouput
Code:
linux:~/bin # ./test_05
rmdir -p -v --ignore-fail-on-non-empty .ssh
rmdir: removing directory, `.ssh'
linux:~/bin # ls /root/.ssh
config  list_user
linux:~/bin #

# 2  
Old 10-26-2012
its doing exactly what it should be doing, the rmdir command wont delete the directory because it has files/directories inside it.

The error message is being suppresed by the option "--ignore-fail-on-non-empty".

Remove the option and you will see the error output, use rm -rf and the directory will be deleted.
This User Gave Thanks to Tommyk For This Post:
# 3  
Old 10-26-2012
I suppose that ignore-fail-on-non-empty just suppresses the error message and sets the exit status

Code:
`--ignore-fail-on-non-empty'
     Ignore each failure to remove a directory that is solely because
     the directory is non-empty.

`-p'
`--parents'
     Remove DIRECTORY, then try to remove each component of DIRECTORY.
     So, for example, `rmdir -p a/b/c' is similar to `rmdir a/b/c a/b
     a'.  As such, it fails if any of those directories turns out not
     to be empty.  Use the `--ignore-fail-on-non-empty' option to make
     it so such a failure does not evoke a diagnostic and does not
     cause `rmdir' to exit unsuccessfully.

As you probably already know, if you intend to remove the .ssh directory and its content, you should use rm instead.
This User Gave Thanks to radoulov For This Post:
# 4  
Old 10-27-2012
Thank

Thank you for helping.

I come from ms world ( nobody is perfect ) and it is not the first time I made this kind of error.

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing sed command inside a bash script

I want to run commands inside a bash script. An example is I want to pass the command in a string as regexp as an argument to the script, then run sed on the bash variable sed.sh regexp sed.sh "-i \"s/<p>//g\"" then call sed "$regexp" $fl (3 Replies)
Discussion started by: Kangol
3 Replies

2. Shell Programming and Scripting

Bash script if condition not executing

issue is with .txt files (7 Replies)
Discussion started by: anil529
7 Replies

3. UNIX for Dummies Questions & Answers

Write pid and command name to a txt file while executing a bash script

Hi All, Just have a requirement, I am executing a bash shell script, my requirement is to catch the pid and job name to a txt file in the same directory, is there anyway to do it? please help me out. Regards Rahul ---------- Post updated at 08:42 AM ---------- Previous update was at... (2 Replies)
Discussion started by: rahulkalra9
2 Replies

4. Shell Programming and Scripting

Bash script errors when executing

I'm working on a script that will search through a directory for MKV files and remux them to MP4. I found a few other scripts around the net that do this, but they all have limitations that don't always get the job done. The main limitation I've found is that most scripts look for the video track... (2 Replies)
Discussion started by: rayne127
2 Replies

5. Shell Programming and Scripting

Bash: executing a command based on organized output

Just learning scripting. I need to remove duplicate managed printers using lpadmin. I have the following script (it's rough and probably a better way to do it) that returns the values as IP (column 1) Printer Name (column 2).command: lpstat -v | grep -E ... (6 Replies)
Discussion started by: Zookpr
6 Replies

6. UNIX for Dummies Questions & Answers

NDR generated by recipient Exchange server complaining about Return DNS

Hi guys We have a client that gets NDR mails when sending emails to the domain "recipient.com" My client's domain is "client.com" My Client setup: Server 2003 Domain Front end Back end Exchange 2003 Standard SP2 1 Linux Firewall/Router The NDR contains: The following... (0 Replies)
Discussion started by: wbdevilliers
0 Replies

7. Shell Programming and Scripting

[bash] Executing script that is held in a variable

Hi, I'm building an installation system that uses separate data files that contain the individual characteristics of each package. Within the data file, I would like to incorporate a section that contains a bash script that is loaded into an array which is then redirected to bash to be... (13 Replies)
Discussion started by: ASGR
13 Replies

8. Shell Programming and Scripting

Executing several bash scripts in succession

Hi, I am new to shell programming. I am trying to automate setting up a network using several scripts. Some of the scripts require to reboot in order to continue with the setup. Is it possible to enter another script as soon as the system reboots. Also, if the last line of the script is bash... (7 Replies)
Discussion started by: fantasyland
7 Replies

9. UNIX for Dummies Questions & Answers

Specified Ksh but executing in bash

Hi, I am a new bie to unix shell programming. I have specified ksh as the first line in my script but when executed it complains. *********** Script=test******************** #!/usr/bin/ksh echo hello print -p 123 ************************************ ++++++++ Execution... (7 Replies)
Discussion started by: akhilnagpal
7 Replies
Login or Register to Ask a Question