CURL
curl -ivk \
-X POST \
-H "Content-Type: application/json" \
-d @file.json \
http://localhost:8080/api
Replace return code with HTTP Status
function CURL() {
curl -k \
-X POST \
-o /dev/null -s -w "%{http_code}\n" \
-H 'Host: wikib.clusterlab.com.br' \
-H "Content-Type: application/json" \
-H "Authorization: $(cat $TOKEN)" \
--data @$1 \
$URL 2>/dev/null
}
export RC=$(CURL $JSONFILE)
if [[ $RC -ne 200 && $RC -ne 201 ]]
then
echo OK
fi
Extract direct from URL
curl -Ss http://somewhere.com/package.tgz | tar xzvf - -C /somedir