First time today i got to know about $DBG_SH # dormant debugging directive (Apr. 92 column) someone used in the shell script. I search around the globe but did not get the exact answer, how and why it is used.
Its Just Being Used at the top of the script as, which i tested now and looks as it gives every bits of Information you are doing at the base code level , here i'm adding and deleting the entries via
ldapmodifycommand and it gives all information what it is does at the background without debugger.
#!/bin/sh
$DBG_SH
flags="-v"
case $1 in
"live") # Live server
LDAPSERVER=ldapprod
ADMIN="uid=bason,ou=people,o=real.com"
pass=""
;;
"dev") # test system
LDAPSERVER=ldapdev
ADMIN="uid=bason,ou=people,o=real.com"
pass=""
;;
*)
echo "Usage: $0 live|dev [ldif filename] [cont]"
echo " live|dev - specify live or dev server"
echo " ldif filename - specify filename containing ldif"
echo " cont - continue on error"
exit 1 ;;
esac
if [ ! -f "$2" ];then
/bin/echo -n "Path to LDIF file: "
read PATH_TO_LDIF
else
PATH_TO_LDIF="$2"
fi
if [ "$3" = "cont" ];then
flags="$flags -c"
fi
if [ `uname -s` = "Linux" ];then
flags="$flags -x"
fi
if [ -z "$pass" ]; then
/bin/echo -n "Password: "
read -s pass
echo
fi
ldapmodify $flags -h $LDAPSERVER -D "$ADMIN" -w $pass -f $PATH_TO_LDIF
exit $?
DBG_SH='echo Hello' mainscriptand the script will echo 'Hello' at the point where$DBG_SHappears. You can substitute more useful commands there, in theory.