19 echo "Usage: $0 [-h|--help] [-t|--timeout <value>] [-f|--file] [-p|--ping] <data>"
21 echo " -h|--help: this usage help."
22 echo " -t|--timeout: timeout for operation in seconds."
23 echo " Defaults to $TIMEOUT__dflt seconds if not provided."
25 echo " -f|--file: the parameter 'data' will be interpreted as a file"
26 echo " with one operation per line. If missing, it will be"
27 echo " a single operation string."
29 echo " -p|--ping: Check the target process id."
30 echo " Returns 1 (dead) or 0 (alive)."
32 echo " data: operation string or file with several operations."
36 echo " $0 \"test|ttps|50\""
37 echo " $0 --file myOperationsList.txt"
38 echo " $0 --timeout 10 --file ./bigList.txt"
44 timeout=$TIMEOUT__dflt
48 while [ $# -gt 0 ]; do
56 [ -z "$timeout" ] && _exit "Missing timeout value"
63 [ -z "$data" ] && _exit "Missing file"
64 [ ! -f "$data" ] && _exit "Can't found provided file '$data'."
73 first=$(echo $1 | cut -c1)
74 [ "$first" = "-" ] && _exit "Unsupported script option: $1. Type '$SCR_BN -h' (or --help) to print the available options."
81 [ -z "$ping" -a -z "$data" ] && _exit "Missing data value"
86 kill -0 $1 2>/dev/null
95 [ ! -f .pid ] && _exit "Can't found '`pwd`/.pid'.\nTry to pgrep your process name and dump pid to that file."
99 [ "$1" = "" -o "$1" = "--help" -o "$1" = "-h" ] && usage
105 [ -n "$ping" ] && exit $res
106 [ $res -ne 0 ] && _exit "Operation error: missing process with pid $PID"
113 echo $data > sigusr2.in
119 # Detect EOF and print all except that last line:
120 count=$((10*timeout))
122 while [ $count -gt 0 ]
126 if tail -1 sigusr2.out | grep "^EOF" >/dev/null; then
134 head --lines=-1 sigusr2.out
136 _exit "Operation error: timeout expired ($timeout seconds)"
139 exception=$(grep "^Operation processed with exception: " sigusr2.out)
140 [ $? -eq 0 ] && _exit "(detected 'exception' within operation output: see 'launcher.trace')"