fixed some input escaping problems when using directories for input

This commit is contained in:
Louwrentius 2009-01-05 10:26:10 +00:00
parent e6f5260b9a
commit 410fd9fbb2
1 changed files with 76 additions and 46 deletions

View File

@ -50,6 +50,7 @@ MAX_DELAY=2
PERCENT="0" PERCENT="0"
PID="$$" PID="$$"
LISTENER_PID="" LISTENER_PID=""
IFS_BACKUP="$IFS"
function showusage { function showusage {
@ -131,50 +132,6 @@ function cleanup {
} }
function get_no_of_cpus {
# Use hyperthreading or not?
HPT=$1
NUMBER=""
if [ -z "$HPT" ]
then
HPT=no
fi
if [ "$HPT" == "yes" ]
then
if [ `uname` == "Linux" ]
then
NUMBER=`cat /proc/cpuinfo | grep processor | wc -l`
elif [ `uname` == "Darwin" ]
then
NUMBER=`sysctl -a hw | grep -w logicalcpu | awk '{ print $2 }'`
else
NUMBER=`cat /proc/cpuinfo | grep processor | wc -l`
fi
elif [ "$HPT" == "no" ]
then
if [ `uname` == "Linux" ]
then
NUMBER=`cat /proc/cpuinfo | grep "cpu cores" | cut -d ":" -f 2 | uniq | sed -e s/\ //g`
elif [ `uname` == "Darwin" ]
then
NUMBER=`sysctl -a hw | grep -w physicalcpu | awk '{ print $2 }'`
else
NUMBER=`cat /proc/cpuinfo | grep "cpu cores" | cut -d ":" -f 2 | uniq | sed -e s/\ //g`
fi
fi
if [ ! -z "$NUMBER" ]
then
echo "$NUMBER"
else
echo "$FUNCNAME ERROR - number of CPUs not obtained."
exit 1
fi
}
# check if ppss is already running. # check if ppss is already running.
function is_running { function is_running {
@ -324,6 +281,76 @@ function log {
} }
function get_no_of_cpus {
# Use hyperthreading or not?
HPT=$1
NUMBER=""
if [ -z "$HPT" ]
then
HPT=no
fi
if [ "$HPT" == "yes" ]
then
if [ `uname` == "Linux" ]
then
NUMBER=`cat /proc/cpuinfo | grep processor | wc -l`
if [ ! "$?" == "0" ]
then
log INFO "$FUNCNAME - cannot determine number of cpu core. Please specify manually with -p."
fi
elif [ `uname` == "Darwin" ]
then
NUMBER=`sysctl -a hw | grep -w logicalcpu | awk '{ print $2 }'`
if [ ! "$?" == "0" ]
then
log INFO "$FUNCNAME - cannot determine number of cpu core. Please specify manually with -p."
fi
else
NUMBER=`cat /proc/cpuinfo | grep processor | wc -l`
if [ ! "$?" == "0" ]
then
log INFO "$FUNCNAME - cannot determine number of cpu core. Please specify manually with -p."
fi
fi
elif [ "$HPT" == "no" ]
then
if [ `uname` == "Linux" ]
then
NUMBER=`cat /proc/cpuinfo | grep "cpu cores" | cut -d ":" -f 2 | uniq | sed -e s/\ //g`
if [ ! "$?" == "0" ]
then
log INFO "$FUNCNAME - cannot determine number of cpu core. Please specify manually with -p."
fi
elif [ `uname` == "Darwin" ]
then
NUMBER=`sysctl -a hw | grep -w physicalcpu | awk '{ print $2 }'`
if [ ! "$?" == "0" ]
then
log INFO "$FUNCNAME - cannot determine number of cpu core. Please specify manually with -p."
fi
else
NUMBER=`cat /proc/cpuinfo | grep "cpu cores" | cut -d ":" -f 2 | uniq | sed -e s/\ //g`
if [ ! "$?" == "0" ]
then
log INFO "$FUNCNAME - cannot determine number of cpu core. Please specify manually with -p."
fi
fi
fi
if [ ! -z "$NUMBER" ]
then
echo "$NUMBER"
else
log INFO "$FUNCNAME ERROR - number of CPUs not obtained."
exit 1
fi
}
function random_delay { function random_delay {
ARGS="$1" ARGS="$1"
@ -399,11 +426,14 @@ function get_all_items {
if [ -z "$INPUT_FILE" ] if [ -z "$INPUT_FILE" ]
then then
ITEMS=`ls -1 $SRC_DIR` ITEMS=`ls -1 $SRC_DIR`
IFS="
"
for x in $ITEMS for x in $ITEMS
do do
ARRAY[$count]=$x ARRAY[$count]="$x"
((count++)) ((count++))
done done
IFS=$IFS_BACKUP
else else
exec 10<$INPUT_FILE exec 10<$INPUT_FILE
@ -496,7 +526,7 @@ function commando {
log DEBUG "Skipping item $ITEM - already processed." # <-- disabled because of possible performance penalty. log DEBUG "Skipping item $ITEM - already processed." # <-- disabled because of possible performance penalty.
else else
#log DEBUG "Starting command on item $ITEM." # <-- disabled because of possible performance penalty. #log DEBUG "Starting command on item $ITEM." # <-- disabled because of possible performance penalty.
EXECME='$COMMAND "$ITEM" > "$JOB_LOG_DIR/$ITEM"' EXECME='$COMMAND"$ITEM" > "$JOB_LOG_DIR/$ITEM"'
eval "$EXECME" eval "$EXECME"
fi fi