Last active
March 12, 2020 20:43
-
-
Save ivanvladimir/9be0aae09e9e4283639fd03dc668d7cf to your computer and use it in GitHub Desktop.
Bash function to update my given IP via Pushbullet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had the issue that the curl command waited and asked for a password. I solved this by putting a ":" directly after -u option.