Necesito un comando de Linux para iniciar una solicitud HTTP y:
Gratis, necesita funcionar en la mayoría de las distribuciones de Linux, bonificación para Mac.
curl no parece poder hacer eso, ya que su --fail
interruptor evita la salida HTTP.
Este pequeño envoltorio bash hace el truco:
#!/bin/bash
# Perform a web request, dump content, and exit with relevant exit code
# Take URL as command-line argument
URL=$1
# Launch HTTP request
HEADERS=`mktemp`
curl --dump-header $HEADERS $URL
# Read the first header (example: HTTP/1.1 200 OK)
HEADER=`head -n 1 $HEADERS`
# Remove temporary file
rm $HEADERS
# Return success if HTTP code OK, or failure for any other HTTP code
if [[ $HEADER == *" 200 "* ]]; then
exit 0
else
exit 1
fi
Licencia: Dominio público
izzy
cat
el archivo yrc=0
, o simplemente derc>0
otra manera)?izzy
$HEADERS
cuando haya terminado, o después de un tiempo tendrá muchos archivos temporales :)izzy