## To use in a program, define the following variables:
## PROGRAM=program-name
## INSTANCE_ID=program-instance-name
## _DEBUG=yes/no
## _LOGGER_SILENT=true/false
## _LOGGER_VERBOSE=true/false
## _LOGGER_ERR_ONLY=true/false
## _LOGGER_PREFIX="date"/"time"/""
## Logger sets {ERROR|WARN}_ALERT variable when called with critical / error / warn loglevel
## When called from subprocesses, variable of main process cannot be set. Status needs to be get via $RUN_DIR/$PROGRAM.Logger.{error|warn}.$SCRIPT_PID.$TSTAMP
if ! type"$BASH" > /dev/null;then
echo"Please run this script only with bash shell. Tested on bash >= 3.2"
exit127
@ -100,7 +88,31 @@ else
RUN_DIR=.
fi
# Get a random number on Windows BusyBox alike, also works on most Unixes
# Get a random number on Windows BusyBox alike, also works on most Unixes that have dd, if dd is not found, then return $RANDOM
function PoorMansRandomGenerator {
localdigits="${1}"# The number of digits to generate
local number
localisFirst=true
iftype dd >/dev/null 2>&1;then
# Some read bytes can't be used, se we read twice the number of required bytes