Improvements & fixes
[anna.git] / example / diameter / launcher / deployments / advanced / batch.sh
diff --git a/example/diameter/launcher/deployments/advanced/batch.sh b/example/diameter/launcher/deployments/advanced/batch.sh
new file mode 100755 (executable)
index 0000000..9699243
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/bash
+> curl_log.txt
+TRACE="--trace-ascii curl_log.txt"
+SERVER=`cat .httpServer`
+
+use () {
+
+   echo "Use: $0 <test file> [time between operations: 0 second by default]"
+   echo
+   echo "     Batch launcher script"
+   echo "     ---------------------"
+   echo
+   echo "     Test file must contain a operations with this syntax: <description>|<operation>|<arg1>|..."
+   echo "     Three operations: code, decode and sendxml:"
+   echo
+   echo "       code|<source>|<target>      i.e.: code|1.xml|2.hex"
+   echo "       decode|<source>|<target>    i.e.: decode|2.hex|1.xml-bis"
+   echo "       sendxml|<source>            i.e.: sendxml|1.xml"
+   echo
+   echo "     Test file example:"
+   echo
+   echo "     $0 1xml-23.txt"
+   echo
+   echo "     where 1xml-23.txt contains:"
+   echo "        Encode 1.xml to 2.hex|code|1.xml|2.hex"
+   echo "        Decode 2.hex to 3.xml (we will diff 1.xml and 3.xml)|decode|2.hex|3.xml"
+   echo
+   echo
+   echo "     Test file could contain any number of operations and could include comments (will be ignored)."
+   echo
+   exit
+}
+
+echo
+echo
+[[ "$1" = "" ]] && use
+LAPSE=${2:-0}
+echo
+echo "Test '$1' is going to be launched:"
+echo
+cat $1
+echo
+echo "Pulse ENTER para lanzar, CTRL+C para abortar..."
+read dummy
+
+while read -r line
+do
+   comment=$(echo $line | grep "^#")
+   ok=
+   [[ "$comment" = "" ]] && { [[ "$line" != "" ]] && ok=s ; }
+   if test "$ok" = "s"
+   then
+      echo "Launching $(echo $line | cut -d'|' -f1) ..."
+      sleep $LAPSE
+      operation=$(echo $line | cut -d'|' -f2-)
+      curl -m 1 --data "$operation" $TRACE ${SERVER}
+   fi
+
+done < $1
+