Skip to content

Instantly share code, notes, and snippets.

@davidcrx
Created May 8, 2018 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcrx/349421ba89a4a0407ce66dd73a95bcb5 to your computer and use it in GitHub Desktop.
Save davidcrx/349421ba89a4a0407ce66dd73a95bcb5 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Número de argumentos no validos, sólo se permite 1"
exit 1
fi
if [ -f $1 ] && [ -n $1 ]; then
echo -e "Todo OK"
else
echo -e "Error en el fitxer, no existeix o està buit"
exit 1;
fi
for x in $(cat $1); do
url=$x
code=$(curl -IL --silent $url --write-out %{http_code} --output /dev/null)
if [ $code -eq 200 ]; then
echo "Pagina $url funcionado! Code 200"
elif [ $code -eq 404 ]; then
echo "Página $url no funcionando! Error 404, archivo no encontrado"
elif [ $code -eq 302 ]; then
echo "Página $url funcionando en HTTP! Code 302"
elif [ $code -eq 301 ]; then
echo "Página $url movida permanentemente! Code 301"
else
echo "Pagina no funcionando"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment