I'm doing ad-hoc profiling on a web service that seems to maintain some state and get slower and slower until eventually things start timing out. I have a simple script that will expose this behavior:
while true
do
RESPONSE_CODE=$( curl --config curl.config )
if [ "$RESPONSE_CODE" -eq "200" ]; then
echo SUCCESS
else
echo FAILURE
fi
done
Along with some headers, cookies, post data, url, etc. curl.config in particular has the lines:
silent
output = /dev/null
write-out = "%{http_code}"
So the only output from curl should be the HTTP status code.
This works fine. What I'd like to do is something like this:
{ time -p RESPONSE_CODE=$(curl --config curl.config) ; } 2>&1 | awk '/real/{print $2;}'
to get a running printout of how long these queries actually take, while still saving curl's output for use in my test. But that doesn't work.
How can I capture the http status from curl AND grab the output of time so I can process both?