1

I have done something in a bash script and my cURL command is no longer showing the status bar. I need to save the HTTP response code to a variable, $status:

I have:

status=$(curl -s -S -o curl.tmp -w %{http_code} --progress-bar -u $USERNAME:$PASSWORD -T "$FILE_TO_UPLOAD" "$FILE_ON_REMOTE_SERVER" )
status=$(($status + 0)) # force integer

if [[ $status > 400 ]]; then
   # an error occurred; do something
fi

Why isn't the progress bar displaying?

1

Using the -s option for "silent mode" will prevent curl from showing the progress bar:

From the curl man page:

-s, --silent

Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it.

Use -S, --show-error in addition to this option to disable progress meter but still show error messages.

See also -v, --verbose and --stderr.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.