Seems to fix some file name issues...

This commit is contained in:
Louwrentius 2009-12-15 23:03:23 +00:00
parent e91f54932c
commit fffccc3e04

38
ppss.sh
View File

@ -38,7 +38,7 @@ trap 'kill_process; ' INT
# Setting some vars. # Setting some vars.
SCRIPT_NAME="Distributed Parallel Processing Shell Script" SCRIPT_NAME="Distributed Parallel Processing Shell Script"
SCRIPT_VERSION="2.40" SCRIPT_VERSION="2.41"
# The first argument to this script can be a mode. # The first argument to this script can be a mode.
MODES="node start config stop pause continue deploy status erase kill" MODES="node start config stop pause continue deploy status erase kill"
@ -117,7 +117,7 @@ showusage_short () {
echo echo
echo "usage: $0 [ -d <sourcedir> | -f <sourcefile> ] [ -c '<command> \"\$ITEM\"' ]" echo "usage: $0 [ -d <sourcedir> | -f <sourcefile> ] [ -c '<command> \"\$ITEM\"' ]"
echo " [ -C <configfile> ] [ -j ] [ -l <logfile> ] [ -p <# jobs> ]" echo " [ -C <configfile> ] [ -j ] [ -l <logfile> ] [ -p <# jobs> ]"
echo " [ -D <delay> ]" echo " [ -D <delay> ] [ -h ] [ --help ]"
echo echo
echo "Examples:" echo "Examples:"
echo " $0 -d /dir/with/some/files -c 'gzip '" echo " $0 -d /dir/with/some/files -c 'gzip '"
@ -128,14 +128,13 @@ showusage_short () {
showusage_normal () { showusage_normal () {
echo echo
echo "|P|P|S|S| - $SCRIPT_NAME -" echo "|P|P|S|S| $SCRIPT_NAME $SCRIPT_VERSION"
echo "Version: $SCRIPT_VERSION"
echo echo
echo "PPSS is a Bash shell script that executes commands in parallel on a set " echo "PPSS is a Bash shell script that executes commands in parallel on a set "
echo "of items, such as files in a directory, or lines in a file." echo "of items, such as files in a directory, or lines in a file."
echo echo
echo "This short summary only discuesses options for stand-alone mode. for all " echo "This short summary only discusses options for stand-alone mode. for a "
echo "options, run PPSS with the options --help" echo "complete listing of all options, run PPSS with the options --help"
echo echo
echo "Usage $0 [ options ]" echo "Usage $0 [ options ]"
echo echo
@ -159,7 +158,7 @@ showusage_normal () {
echo -e "--log | -l Sets the name of the log file. The default is ppss-log.txt." echo -e "--log | -l Sets the name of the log file. The default is ppss-log.txt."
echo echo
echo -e "--processes | -p Start the specified number of processes. Ignore the number of available" echo -e "--processes | -p Start the specified number of processes. Ignore the number of available"
echo -e " CPU's." echo -e " CPUs."
echo echo
echo -e "--delay | -D Adds an initial random delay to the start of all parallel jobs to spread" echo -e "--delay | -D Adds an initial random delay to the start of all parallel jobs to spread"
echo -e " the load. The delay is only used at the start of all 'threads'." echo -e " the load. The delay is only used at the start of all 'threads'."
@ -181,8 +180,7 @@ fi
showusage_long () { showusage_long () {
echo echo
echo "|P|P|S|S| - $SCRIPT_NAME -" echo "|P|P|S|S| $SCRIPT_NAME $SCRIPT_VERSION"
echo "Version: $SCRIPT_VERSION"
echo echo
echo "PPSS is a Bash shell script that executes commands in parallel on a set " echo "PPSS is a Bash shell script that executes commands in parallel on a set "
echo "of items, such as files in a directory, or lines in a file." echo "of items, such as files in a directory, or lines in a file."
@ -198,6 +196,7 @@ showusage_long () {
echo " start Starting PPSS on nodes." echo " start Starting PPSS on nodes."
echo " pause Pausing PPSS on all nodes." echo " pause Pausing PPSS on all nodes."
echo " stop Stopping PPSS on all nodes." echo " stop Stopping PPSS on all nodes."
echo " node Running PPSS as a node, requires additional options."
echo echo
echo "Options are:" echo "Options are:"
echo echo
@ -221,7 +220,7 @@ showusage_long () {
echo -e "--log | -l Sets the name of the log file. The default is ppss-log.txt." echo -e "--log | -l Sets the name of the log file. The default is ppss-log.txt."
echo echo
echo -e "--processes | -p Start the specified number of processes. Ignore the number of available" echo -e "--processes | -p Start the specified number of processes. Ignore the number of available"
echo -e " CPU's." echo -e " CPUs."
echo echo
echo -e "--delay | -D Adds an initial random delay to the start of all parallel jobs to spread" echo -e "--delay | -D Adds an initial random delay to the start of all parallel jobs to spread"
echo -e " the load. The delay is only used at the start of all 'threads'." echo -e " the load. The delay is only used at the start of all 'threads'."
@ -589,7 +588,7 @@ init_vars () {
echo 0 > $ARRAY_POINTER_FILE echo 0 > $ARRAY_POINTER_FILE
FIFO=$PPSS_DIR/fifo-$RANDOM-$RANDOM FIFO=/tmp/ppss-fifo-$RANDOM-$RANDOM
if [ ! -e "$FIFO" ] if [ ! -e "$FIFO" ]
then then
@ -864,6 +863,7 @@ deploy_ppss () {
log DEBUG "SSH SERVER $SSH_SERVER is also a node." log DEBUG "SSH SERVER $SSH_SERVER is also a node."
INSTALLED_ON_SSH_SERVER=1 INSTALLED_ON_SSH_SERVER=1
exec_cmd "mkdir -p $PPSS_HOME_DIR/$JOB_LOG_DIR" exec_cmd "mkdir -p $PPSS_HOME_DIR/$JOB_LOG_DIR"
exec_cmd "mkdir -p $ITEM_LOCK_DIR"
fi fi
done done
if [ "$INSTALLED_ON_SSH_SERVER" == "0" ] if [ "$INSTALLED_ON_SSH_SERVER" == "0" ]
@ -871,6 +871,7 @@ deploy_ppss () {
log DEBUG "SSH SERVER $SSH_SERVER is not a node." log DEBUG "SSH SERVER $SSH_SERVER is not a node."
deploy "$SSH_SERVER" deploy "$SSH_SERVER"
exec_cmd "mkdir -p $PPSS_HOME_DIR/$JOB_LOG_DIR" exec_cmd "mkdir -p $PPSS_HOME_DIR/$JOB_LOG_DIR"
exec_cmd "mkdir -p $ITEM_LOCK_DIR"
fi fi
fi fi
} }
@ -1084,6 +1085,7 @@ escape_item () {
sed s/\\|/\\\\\\\\\\\\\\|/g | \ sed s/\\|/\\\\\\\\\\\\\\|/g | \
sed s/\&/\\\\\\\\\\\\\\&/g | \ sed s/\&/\\\\\\\\\\\\\\&/g | \
sed s/\;/\\\\\\\\\\\\\\;/g | \ sed s/\;/\\\\\\\\\\\\\\;/g | \
sed s/\\\//\\\\\\\\\\\\\\_/g | \
sed s/\(/\\\\\\\\\\(/g | \ sed s/\(/\\\\\\\\\\(/g | \
sed s/\)/\\\\\\\\\\)/g ` sed s/\)/\\\\\\\\\\)/g `
} }
@ -1217,13 +1219,13 @@ get_all_items () {
if [ ! -z "$SSH_SERVER" ] # Are we running stand-alone or as a slave?" if [ ! -z "$SSH_SERVER" ] # Are we running stand-alone or as a slave?"
then then
log DEBUG "Running as slave, input file has been pushed (hopefully)." log DEBUG "Running as slave, input file has been pushed (hopefully)."
if [ ! -e "$INPUT_FILE" ] fi
then if [ ! -e "$INPUT_FILE" ]
log ERROR "Input file $INPUT_FILE does not exist." then
set_status "ERROR" log ERROR "Input file $INPUT_FILE does not exist."
cleanup set_status "ERROR"
exit 1 cleanup
fi exit 1
fi fi
exec 10<"$INPUT_FILE" exec 10<"$INPUT_FILE"