Mercurial > hg > cc > azure
comparison workers/bin/test1.sh @ 13:bba589cab837
shrinkJSON.sh: minimise "jq ." output
test1.sh: fix lrand regression
[_]findPDFs.sh: extract responses with application/pdf Content-Type
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Fri, 12 Oct 2018 08:51:50 +0000 |
parents | 36b5d379909a |
children |
comparison
equal
deleted
inserted
replaced
12:be1034183e03 | 13:bba589cab837 |
---|---|
8 echo $$ > test1.pid | 8 echo $$ > test1.pid |
9 proc=$1 | 9 proc=$1 |
10 res=res$proc | 10 res=res$proc |
11 home=$2 | 11 home=$2 |
12 shift 2 | 12 shift 2 |
13 function lrand { | |
14 # cheap bad little random number generator | |
15 echo $(( 1 + ($(openssl rand 1 | od -d | head -1 | tr -s ' ' | cut -f 2 -d ' ') % $1))) | |
16 } | |
13 if [ "$1" = "-t" ] | 17 if [ "$1" = "-t" ] |
14 then | 18 then |
15 shift | 19 shift |
16 pause=$proc | 20 pause=$proc |
17 else | 21 else |
18 pause=$(lrand 60) | 22 pause=$(lrand 60) |
19 fi | 23 fi |
20 wp=$1 | 24 wp=$1 |
21 touch .running | 25 touch .running |
22 function lrand { | |
23 # cheap bad little random number generator | |
24 echo $(( 1 + ($(openssl rand 1 | od -d | head -1 | tr -s ' ' | cut -f 2 -d ' ') % $1))) | |
25 } | |
26 function tryRead { | 26 function tryRead { |
27 m=0 | 27 m=0 |
28 set -o pipefail | 28 set -o pipefail |
29 until if [ $((m+=1)) -gt 5 ]; then echo "tried to read $1 5 times w/o success, giving up" 1>&2; return 1; fi && \ | 29 until if [ $((m+=1)) -gt 5 ]; then echo "tried to read $1 5 times w/o success, giving up" 1>&2; return 1; fi && \ |
30 curl -s --insecure -o - "$1"| zcat | fgrep msgtype=response | \ | 30 curl -s --insecure -o - "$1"| zcat | fgrep msgtype=response | \ |