Skip to content

Instantly share code, notes, and snippets.

@ivanvladimir
Last active March 12, 2020 20:43
Show Gist options
  • Save ivanvladimir/9be0aae09e9e4283639fd03dc668d7cf to your computer and use it in GitHub Desktop.
Save ivanvladimir/9be0aae09e9e4283639fd03dc668d7cf to your computer and use it in GitHub Desktop.
Bash function to update my given IP via Pushbullet
#!/bin/bash
function pb_msg {
curl -vs -o /dev/null \
-u PUSHBULLET_TOKEN \
https://api.pushbullet.com/v2/pushes \
-d type=note \
-d title="$1" \
-d body="$2" 2> /dev/null
}
curl http://ipecho.net/plain -o ~/.plain
NEW_IP=`cat ~/.plain`
OLD_IP=`cat ~/Dropbox/IP.txt`
if [ "$NEW_IP" != "$OLD_IP" ]
then
pb_msg "[NEW IP]" ${NEW_IP}
echo $NEW_IP > ~/Dropbox/IP.txt
fi
@joshartman
Copy link

I had the issue that the curl command waited and asked for a password. I solved this by putting a ":" directly after -u option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment