#!/bin/bash

for i in `find . -name "*.ini" | sort -t"-" -n -k9`
do
        BASE=${i%.ini}
	if [ ! -f ${BASE}.LOCK -a ! -f ${BASE}.sca ]
	then
		touch ${BASE}.LOCK
		echo "`hostname`: ${BASE} started at `date`..."
		../../bin/OverSim -UCmdenv -f ${BASE}.ini 2>&1 >/tmp/${BASE}.debug
		echo "...returned with $?"
		mv /tmp/${BASE}.debug .
		rm ${BASE}.LOCK
	fi
done

echo "`hostname`: finished."
