Ответ 1
Это то, что я использую в одном из моих скриптов сборки:
curl "${UPLOAD_URL}" \
--progress-bar \
--verbose \
-F build="${BUILD}" \
-F version="${VERSION}" \
-F ipa="@${IPA};type=application/octet-stream" \
-F assets="@-;type=text/xml" \
-F replace="${REPLACE}" \
-A "${CURL_FAKE_USER_AGENT}" \
<<< "${ASSETS}" \
| tee -a "${LOG_FILE}" ; test ${PIPESTATUS[0]} -eq 0
Параметры -F
и -A
, вероятно, вас не интересуют, но полезными являются:
curl "${UPLOAD_URL}" --progress-bar
который сообщает curl
показывать индикатор выполнения (вместо стандартного "индикатора выполнения" ) во время загрузки и:
| tee -a "${LOG_FILE}" ; test ${PIPESTATUS[0]} -eq 0
который добавляет вывод команды в файл журнала, а также отсылает ее на stdout
. Часть test ${PIPESTATUS[0]} -eq 0
делает это так, что статус выхода этой строки (который находится в bash script) - это тот же код выхода, что и команда curl
, а не статус выхода команды tee
(необходимо, потому что tee
- фактически последняя команда, выполняемая в этой строке, а не curl
).
От man curl
:
PROGRESS METER
curl normally displays a progress meter during operations, indicating the amount of transferred data, transfer speeds and estimated time left, etc.
curl displays this data to the terminal by default, so if you invoke curl to do an operation and it is about to write data to the terminal, it disables the progress meter as otherwise it would mess up the
output mixing progress meter and response data.
If you want a progress meter for HTTP POST or PUT requests, you need to redirect the response output to a file, using shell redirect (>), -o [file] or similar.
It is not the same case for FTP upload as that operation does not spit out any response data to the terminal.
If you prefer a progress "bar" instead of the regular meter, -# is your friend.
OPTIONS
-#, --progress-bar
Make curl display progress as a simple progress bar instead of the standard, more informational, meter.