#!/bin/bash

# this script's parent
p="$(dirname "$0")"
if ! cd "$p" 
then
	echo "trouble trying to cd to \"$p\": exiting"
	exit 2
fi

# root under which to make each new batch's base-directory
B="/home/public/nt_sim"

# name of this batch's base-directory
b="$B/tst_b1"


# number of jobs 
N=32

if [ -d "$b" ]
then
	echo "new batch base-directory \"$b\" exists: exiting"
	exit 2
else
	mkdir -pv "$b/logs"
fi

for ((i=1; i<=$N; i++))
do
	I=`printf "%06d" $i`;	
	mkdir -pv "$b/work/$I" && \
	echo -e '#!/bin/sh\n\nsleep 2;\n(date; hostname; uname -a) >res.out\n' >"$b/work/$I/run"
	chmod -v a+x "$b/work/$I/run"
done

cp -Rv batching_scripts/* "$b/"
cp -Rv hosts.list "$b/"

