-
-
Save stephenturner/bbd16f517a1e14b98450 to your computer and use it in GitHub Desktop.
Uses the http://textbelt.com/ API to send a text message.
This file contains 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 | |
# Uses the http://textbelt.com/ API to send a text message. | |
# The PHONE environment variable must be set, e.g., in your .bashrc., e.g. | |
# export PHONE=1234567890 | |
# Usage: txt "<a text message to send>" | |
# Example 1 | |
# When long_running_command is done successfully, this command | |
# will send a text to the indicated number saying: | |
# "done with long running command (from myusername on myhostname)" | |
# long_running_command && txt 'done with long running command' | |
# Example 2 | |
# Tells you whether command succeeded or failed | |
# command && txt success || txt fail | |
if [ -z "$PHONE" ]; then | |
echo 'Environment variable $PHONE is not set. Set this in .bashrc and try again.' | |
exit 1 | |
else | |
curl --silent -X POST http://textbelt.com/text -d number=$PHONE -d "message=$1 (from $(whoami) on $(hostname))" > /dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment