--- /dev/null
+#!/bin/bash
+
+#
+# dripfeed.sh
+#
+# A script to perform several actions at a time from a file.
+#
+# Colin McCabe
+#
+
+die() {
+ echo $1
+ exit 1
+}
+
+usage() {
+ cat <<EOF
+dripfeed.sh: read actions from a file and do them.
+-f [file]: set input file
+-h: this help
+-p [number of processes]: set number of processes to use
+EOF
+}
+
+dripfeed() {
+ while true; do
+ for (( nline=1; nline <= ${nlines}; nline++ )) do
+ nline_text=$(printf '%03d' ${nline})
+ [ $? -ne 0 ] && die "printf failed for ${nline}"
+ mkdir ${nline_text} &>/dev/null && break
+ done
+ echo "nline = $nline, nlines = $nlines"
+ [ $nline -gt $nlines ] && exit 0
+ line=$(head -n ${nline} ${input_file} | tail -n 1)
+ echo $line
+ $line
+ done
+}
+
+input_file=""
+num_procs=1
+while getopts "f:hp:" flag; do
+ case $flag in
+ f) input_file=$OPTARG;;
+ h) usage; exit 0;;
+ p) num_procs=$OPTARG;;
+ *) echo "getopts error"
+ echo
+ usage
+ exit 1;;
+ esac
+ #echo "$flag" $OPTIND $OPTARG
+done
+[ x${input_file} == x ] && die "you must supply an input file with -f"
+nlines=$(wc -l "${input_file}" | awk '{ print $1 }')
+[ $? -ne 0 ] && die "wc -l ${input_file} failed"
+
+for (( idx=0; idx < ${num_procs}; idx++ )) do
+ { dripfeed; } &
+done
+wait
+
+exit 0