19 echo "Usage: $0 [-h|--help] [-t|--timeout <value>] [-f|--file] <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 " data: operation string or file with several operations."
33 echo " $0 \"test|ttps|50\""
34 echo " $0 --file myOperationsList.txt"
35 echo " $0 --timeout 10 --file ./bigList.txt"
41 timeout=$TIMEOUT__dflt
44 while [ $# -gt 0 ]; do
52 [ -z "$timeout" ] && _exit "Missing timeout value"
59 [ -z "$data" ] && _exit "Missing file"
60 [ ! -f "$data" ] && _exit "Can't found provided file '$data'."
65 first=$(echo $1 | cut -c1)
66 [ "$first" = "-" ] && _exit "Unsupported script option: $1. Type '$SCR_BN -h' (or --help) to print the available options."
73 [ -z "$data" ] && _exit "Missing data value"
78 kill -0 $1 2>/dev/null
79 [ $? -ne 0 ] && _exit "Operation error: missing process with pid $1"
87 [ ! -f .pid ] && _exit "Can't found '`pwd`/.pid'.\nTry to pgrep your process name and dump pid to that file."
91 [ "$1" = "" -o "$1" = "--help" -o "$1" = "-h" ] && usage
99 echo $data > sigusr2.in
105 # Detect EOF and print all except that last line:
106 count=$((10*timeout))
108 while [ $count -gt 0 ]
112 if tail -1 sigusr2.out | grep "^EOF" >/dev/null; then
120 head --lines=-1 sigusr2.out
122 _exit "Operation error: timeout expired ($timeout seconds)"
125 exception=$(grep "^Operation processed with exception: " sigusr2.out)
126 [ $? -eq 0 ] && _exit "(detected 'exception' within operation output: see 'launcher.trace')"