Recursively delete empty folders with verbose output
This should be fairly simple, but I am not sure what i’m missing. I’d like to recursively delete empty directories, and get an output for what’s being deleted, this command works for sure, but I just can’t print the actions of -excec verbosely. while [ -n "$(find . -depth -type d -empty -exec rm -v -rf {} +)" ]; do :; done by recursively I mean, I want to keep deleting empty folders, until there’s [...]
Continue Reading »Adding a timestamp to bash script log
I have a constantly running script that I output to a log file: script.sh >> /var/log/logfile I’d like to add a timestamp before each line that is appended to the log. Like: Sat Sep 10 21:33:06 UTC 2011 The server has booted up. Hmmph. Is there any jujitsu I can use? Asked by Antonius Bloch You can pipe the script’s output through a loop that prefixes the current date and time: ./script.sh | while IFS= [...]
Continue Reading »Bash, running a command as an argument with arguments, and the continuing the original command
Sorry for the very confusing title, but here’s what im trying to do: TORQUEBOX_START=”$TORQUEBOX_HOME/jboss/bin/standalone.sh” TORQUEBOX_START_ARGS=”–server-config=standalone-ha.xml”start-stop-daemon –start –quiet –chuid $DAEMONUSER \ –exec “${TORQUEBOX_START}” — ${TORQUEBOX_START_ARGS} –pidfile $PIDFILE –make-pidfile — -c $TORQUEBOX_SERVER >> $LOGFILE 2>&1 & I need to run the TORQUEBOX_START with its arguments in the –exec argument. I tried using — to pass the args to it. But from there I dont really know how i can pop back to passing args to the original [...]
Continue Reading »Ordinary users are able to read /etc/passwd, is this a security hole?
ls -l /etc/passwd gives $ ls -l /etc/passwd -rw-r–r– 1 root root 1862 2011-06-15 21:59 /etc/passwd So an ordinary user can read the file. Is this a security hole? Asked by abc Actual password hashes are stored in /etc/shadow, which is not readable by regular users. /etc/passwd holds other information about user ids and shells that must be readable by all users for the system to function. Answered by Michael Check more discussion of this [...]
Continue Reading »escaping spaces in shell script
yesterday=”2010-06-23 00:00:00″ today=”2010-06-24 00:00:00″ mywhere=”lastupdate>’$yesterday’ and lastupdate<’$today’”mysqldump $param ticket –no-create-info –where=\”$mywhere\” The last line of above shell script would return something like this… + mysqldump -uroot -d –compact ahmadpur ticket –no-create-info –where=”lastupdate>’2010-06-23 00:00:00′ and lastupdate<’2010-06-24 00:00:00′” mysqldump: Couldn’t find table: “00:00:00′” There is an error in the mysqldump command execution. But if I copy paste the same line, it runs successfully. Do I need to escape the spaces in shell script output? if yes, how? [...]
Continue Reading »how to see process status with full details
I run the script – my_script.ksh as process with 5 long arguments on my solaris/linux machine ( example 1 ) , Later I verify the process by ps -ef | grep my_script.ksh I don’t understand way I not get the all arguments from ps -ef ? , ( see example 2 ) or maybe ps command have limitation to display a long line ? , or maybe need to write the ps command with some [...]
Continue Reading »Cannot change chmod from bash script
I made a script to copy an image to a temporary directory, convert it to an another format, then move it to a final directory. But i can’t get the chmod command to work, the file is copied to the temporary directory but it’s chmod is stuck on -rw——- (the original chmod of the file). If i apply a 777 chmod on the original file, the copied one get a -rwx—— instead of a -rwxrwxrwx [...]
Continue Reading »Escaping special characters while sourcing file in bash
I’v written a script that sources a bash shell fragment. The shell fragment is supposed to be a kind of configuration file, basically it’s a bunch of bash variable. The issue here is when some of those string variable contain characters that should be escaped. As they aren’t escape, the script might faill later on or have undesired behavior. At the moment, my script is validating the shell fragment (the configuration file) bash syntax (bash [...]
Continue Reading »Running drupal as root in order for it to run bash scripts
I store a website on redhat and using drupal. There is a button on the site that activates a php script and that php script use exec to activate bash script on the server. Right now the script is not being run, i guess because of permission reason – the drupal user that runs the bash does not have root access to run the bash script. How can i add the user as a root [...]
Continue Reading »linux + create Shortcut command
I am not sure if I performed the following illegal or true but what I need is – to create set of ready commands so if I need to use , for example to match IP address with 4 octet I can use the command – command_that_match_four_octet Please advice if I performed correctly the following and, I want to know if the following syntax will not cause troubles. [root@su1a /tmp]# command_that_match_four_octet=” grep ‘[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}’ “[root@su1a /tmp]# [...]
Continue Reading »Recent Posts
- Cron expression that runs every 5 minutes from 1:30 am – 6:00 am [duplicate]
- Understanding redundant power supplies
- Is there a way for administrators to disable users from installing Firefox extensions?
- Is there research material on NTP accuracy available?
- How to create a limited “domain admin” that does not have access to domain controllers?



