Wednesday, January 21, 2009

A thttpd server start up script that kills the existing instance and restart the thttpd server (not requiring reboot)

#!/bin/sh
if [ -n "`pidof mythttpd`" ]; then
killall mythttpd 2>/dev/null
fi
/opt/sbin/mythttpd -C /opt/etc/mythttpd.conf

Its just a tip which you can use to automate your instincts to kill processes!!

Thursday, January 15, 2009

How to check if a parameter is an integer in bash?

#!/ash/sh
val=$1
if [ ! $(echo "$val" | grep -E "^[0-9]+$") ]; then
echo $val is not a valid integer
else
echo $val is an integer
exit 1
fi


Syntax: ./check.sh 45