CURL

De Wiki Clusterlab.com.br
Revisão de 16h50min de 27 de abril de 2023 por Damato (discussão | contribs)
Ir para navegação Ir para pesquisar
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 "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