969924321110c4d63f3a7ac3061f1e2498d161f2
[anna.git] / example / diameter / launcher / deployments / advanced / batch.sh
1 #!/bin/bash
2 > curl_log.txt
3 TRACE="--trace-ascii curl_log.txt"
4 SERVER=`cat .httpServer`
5
6 use () {
7
8    echo "Use: $0 <test file> [time between operations: 0 second by default]"
9    echo
10    echo "     Batch launcher script"
11    echo "     ---------------------"
12    echo
13    echo "     Test file must contain a operations with this syntax: <description>|<operation>|<arg1>|..."
14    echo "     Three operations: code, decode and sendxml:"
15    echo
16    echo "       code|<source>|<target>      i.e.: code|1.xml|2.hex"
17    echo "       decode|<source>|<target>    i.e.: decode|2.hex|1.xml-bis"
18    echo "       sendxml|<source>            i.e.: sendxml|1.xml"
19    echo
20    echo "     Test file example:"
21    echo
22    echo "     $0 1xml-23.txt"
23    echo
24    echo "     where 1xml-23.txt contains:"
25    echo "        Encode 1.xml to 2.hex|code|1.xml|2.hex"
26    echo "        Decode 2.hex to 3.xml (we will diff 1.xml and 3.xml)|decode|2.hex|3.xml"
27    echo
28    echo
29    echo "     Test file could contain any number of operations and could include comments (will be ignored)."
30    echo
31    exit
32 }
33
34 echo
35 echo
36 [[ "$1" = "" ]] && use
37 LAPSE=${2:-0}
38 echo
39 echo "Test '$1' is going to be launched:"
40 echo
41 cat $1
42 echo
43 echo "Pulse ENTER para lanzar, CTRL+C para abortar..."
44 read dummy
45
46 while read -r line
47 do
48    comment=$(echo $line | grep "^#")
49    ok=
50    [[ "$comment" = "" ]] && { [[ "$line" != "" ]] && ok=s ; }
51    if test "$ok" = "s"
52    then
53       echo "Launching $(echo $line | cut -d'|' -f1) ..."
54       sleep $LAPSE
55       operation=$(echo $line | cut -d'|' -f2-)
56       curl -m 1 --data "$operation" $TRACE ${SERVER}
57    fi
58
59 done < $1
60