Skip to content

Instantly share code, notes, and snippets.

@maagmirror
Created October 31, 2023 15:40
Show Gist options
  • Save maagmirror/65344f372ca8b12b18313a71ffee445a to your computer and use it in GitHub Desktop.
Save maagmirror/65344f372ca8b12b18313a71ffee445a to your computer and use it in GitHub Desktop.
get the ip and send it to an api
#!/bin/sh
# Obtener la dirección IP pública
public_ip=$(curl -s https://ipinfo.io/ip)
# URL de destino (reemplaza con la URL a la que deseas enviar la IP)
url="https://test.com/dlinkip.php?ip=$public_ip"
# Realizar la solicitud GET
curl -s "$url" > /dev/null
# Verificar si la solicitud se realizó correctamente
if [ $? -eq 0 ]; then
echo "IP enviada con éxito: $public_ip"
else
echo "Error al enviar la IP"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment