Quote strings properly

This commit is contained in:
Trevor Vallender 2024-10-03 10:45:06 +01:00
parent 60cf058e04
commit cc3a3e668f
1 changed files with 9 additions and 8 deletions

View File

@ -7,20 +7,21 @@ if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi
RATE_CHANGE_FACTOR=$1 RATE_CHANGE_FACTOR=$1
IFS=" " read -r -a OPTS <<< $2 IFS=" " read -r -a OPTS <<< $2
URL=${OPTS[0]}; METHOD=${OPTS[1]}; RATE=${OPTS[2]}; BODY=${OPTS[3]} URL=${OPTS[0]}; METHOD=${OPTS[1]}; RATE=${OPTS[2]}; BODY=${OPTS[3]}
SLEEP_TIME=$(expr 60 / $RATE / $RATE_CHANGE_FACTOR) SLEEP_TIME=$(perl -e "print 60.0 / $RATE / $RATE_CHANGE_FACTOR")
until false send_req () {
do COMMAND="curl -X $METHOD --header 'Content-Type: application/json' --data '$BODY' -s '$URL' -o /dev/null"
curl --header "Content-Type: application/json" \ eval $COMMAND
--data $BODY \
-X $METHOD \
-s $URL \
-o /dev/null
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
printf '%s' "." printf '%s' "."
else else
printf '%s' "x" printf '%s' "x"
fi fi
}
until false
do
send_req &
sleep $SLEEP_TIME sleep $SLEEP_TIME
done done