-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrunsimu.sh
executable file
·45 lines (35 loc) · 1.09 KB
/
runsimu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
FILE=$1
SIMUNR=$2
EXAMPLENR=$3
if [ -z "$FILE" ] ||
[ ! -e "$FILE" ] ||
! ./dealer -p 1 < $FILE > /dev/null; then
echo "*** First parameter must be the simulation file."
exit 1
fi
if [ -z "$SIMUNR" ]; then
SIMUNR=400
fi
if [ -z "$EXAMPLENR" ]; then
EXAMPLENR=30
fi
case $SIMUNR in
''|*[!0-9]*)
echo "*** Second parameter can only be a integer setting simulation production limit"
exit 1 ;;
esac
case $EXAMPLENR in
''|*[!0-9]*)
echo "*** Third parameter can only be a integer setting example hand production limit"
exit 1
esac
echo "#***\n" >> $FILE
sed -i -e '/^#\*\*\*/,$d' -e "s/produce .*/produce $EXAMPLENR/" -e 's/^\(\tave\|\tfreq\)/#\1/' -e 's/^#\tprint/\tprint/' $FILE
echo "#***\n#Example deals for the biding\n#" >> $FILE
./dealer < $FILE | sed 's/^/#/' | tee -a $FILE
sed -i -e "s/produce .*/produce $SIMUNR/" -e 's/^#\(\tave\|\tfreq\)/\1/' -e 's/^\tprint/#\tprint/' $FILE
echo "\n#Simulation results\n#" >> $FILE
./dealer < $FILE | sed 's/^/#/' | tee -a $FILE
sed -i -e "s/produce .*/produce $EXAMPLENR/" -e 's/^\(\tave\|\tfreq\)/#\1/' -e 's/^#\tprint/\tprint/' $FILE
exit 0