Curl does have different exit status to inform how the program finished. Running your example, I got exit status 5 "Couldn't resolve proxy", and then 6 "Couldn't resolve host". You can see a list of Curl exit status here: https://ec.haxx.se/usingcurl-returns.html
curl https://invvvv.usvvv.com/agg/tari?uswg-key=8e3eedhhhh4a9a370605637 --output output.zip --proxy proxy-az.azure.ghop.fguiop.com:8080 ; echo "RETURN CODE: $?"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (5) Could not resolve proxy: proxy-az.azure.ghop.fguiop.com
RETURN CODE: 5
curl https://invvvv.usvvv.com/agg/tari?uswg-key=8e3eedhhhh4a9a370605637 --output output.zip ; echo "RETURN CODE: $?"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: invvvv.usvvv.com
RETURN CODE: 6
Actually, I'm getting an error running the example line, if you want to capture stdout of a program, you might include it between $(). Although, you are redirecting stdout with --output output.zip
.
Here is a example storing curl stdout in a variable.
location=$(curl example.com)
if [ $? -eq 0 ]; then
echo "Success"
else
echo "Failure $?"
fi
echo $location
However, if what you want to test is the HTTP response code, you can use the example below.
curl -s -o response.txt -w "%{http_code}" http://example.com
More details on this here Curl to return http status code along with the response