Last active
August 29, 2015 13:58
-
-
Save ruediger/10270883 to your computer and use it in GitHub Desktop.
run hermsk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function die() { | |
echo "Error: ${@}!" >&2 | |
exit 1 | |
} | |
: "${INPUT_DATA_PATH:=~/develop/hermsk/mpauli/}" | |
input= | |
if [[ -f "$1" ]]; then | |
if [[ "$1" =~ ^/ ]]; then # absolute | |
input="$1" | |
else | |
input="$(pwd)/$1" | |
fi | |
else | |
input="${INPUT_DATA_PATH}$1.dat" | |
fi | |
[[ -f "$input" ]] || die "No input '$input' ('$1') found" | |
echo "Input: $input" | |
outpath=$(pwd) | |
echo "Out: $outpath" | |
resprefix=$(basename "$input") | |
resprefix=${resprefix%.dat} | |
echo "Result prefix: $resprefix" | |
: "${hermsk:=$(pwd)/hermsk}" | |
[[ -x "$hermsk" ]] || die "No executable '$hermsk' found" | |
echo "Executable: $hermsk" | |
tmp=$(mktemp -d) || die "tmpdir" | |
trap "rm -rf -- '$tmp'" EXIT | |
if cd "$tmp" && ln -s "$input" 'input.dat' && "$hermsk"; then | |
for i in *.out; do | |
mv -- "$i" "$outpath/$resprefix-$i" | |
done | |
else | |
trap - EXIT | |
echo "Error while executing hermsk! Tmp dir: $tmp" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment