Sergio_Istea

elif.sh

Apr 26th, 2021 (edited)
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.97 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. read -p "Ingrese el sitio web con el que testear conectividad (ej. google.com)" SITE
  4. read -p "Ingrese una ip de inteneret (ej. 172.217.172.110): " IPINTERNET
  5. read -p "Ingrese ip de gateway (ej. 192.168.1.1): " GATEWAY
  6. ping -c 1 $SITE &> /dev/null
  7.  
  8. if [ $? -eq 0 ] ; then
  9.     echo "Se testeo con un ping a google.com"
  10.     echo "Se obtuvo respuesta"
  11.     echo "Hay internet"
  12.     exit 0
  13. elif ping -c 1 $IPINTERNET &> /dev/null; then # este bloque se ejecuta si al condicion anterior FALSE
  14.     echo "La resolucion de nombres de dominio no funciona"
  15.     echo "aunque el ping hacia la ip de internet ( $IPINTERNET  ) responde correctamente"
  16.     exit 1
  17. elif ping -c 1 $GATEWAY &> /dev/null; then
  18.     echo "El gateway responde, pero no parece haber conectividad hacia internet"
  19.     echo "Responde el ping al gateway"
  20.     exit 1
  21. else # opcional
  22.     echo "Se hicieron pruebas a '$SITE', '$IPINTERNET' y '$GATEWAY' y no se obtuvieron respuestas"
  23.     echo "Revise la configuracion de su sistema"
  24.     exit 1
  25. fi
  26.  
Add Comment
Please, Sign In to add comment