I want to check speed of a website with a shell script. I'm using time format to get number result but I have problem with comparator. This is my script:
#!/bin/bash
TIMEFORMAT=%E
TOTAL=`time wget -pq --no-cache --delete-after -H https://www.netflix.com 2>&1`
echo $TOTAL
if [[ "$TOTAL" -gt 0 ]]; then
echo 'YES'
else
echo 'NO'
fi
Result was about greather than 2, but result was always no.
EDIT
This is result of script
2,119
NO
EDIT 2
Thanks, resolved this way
#!/bin/bash
start=$(date +%s)
time wget -pq --no-cache --delete-after -H https://www.netflix.com 2>&1
end=$(date +%s)
total=$(($end-$start))
echo "Elapsed Time: $(($total)) seconds"
if [[ $total -gt 1 ]]; then
echo 'YES'
else
echo 'NO'
fi