Skip to content

Instantly share code, notes, and snippets.

@nhomble
Last active August 29, 2015 14:04
Show Gist options
  • Save nhomble/c9623769d8e512d213e7 to your computer and use it in GitHub Desktop.
Save nhomble/c9623769d8e512d213e7 to your computer and use it in GitHub Desktop.
message me.. never be late again!
#!/usr/bin/env bash
usage(){
cat << EOF
usage: $0 options
message me, send text message to a phone
PLEASE have an ssh key, cause otherwise this makes
no sense!
OPTIONS:
-h help
-d delay in bash Sleep syntax
-c phone carrier
-n phone number
-e server
-m user
-s subject
EOF
}
getCarrierDomain(){
CDOMAIN="vtext.com"
}
validateTime(){
VALID_TIME=true
if [[ ! $VALID_TIME ]]; then
echo "bad input delay"
exit
fi
}
SUBJECT=$(hostname)
CARRIER="verizon"
TIME="10m"
NUMBER=""
SERVER=""
NAME="alert"
CDOMAIN=
while getopts "hd:c:n:e:s:m:" OPTION
do
case $OPTION in
h)
usage
exit
;;
d)
TIME=$OPTARG
;;
c)
CARRIER=$OPTARG
;;
n)
NUMBER=$OPTARG
;;
e)
SERVER=$OPTARG
;;
s)
SUBJECT=$OPTARG
;;
m)
NAME=$OPTARG
;;
?)
usage
exit
;;
esac
done
validateTime
getCarrierDomain
# read message
MESSAGE="\\n"
while read line; do
MESSAGE+=$line\\n
done
{
sleep $TIME
ssh $SERVER 'echo -e "'"$MESSAGE"'" | mailx -r '$NAME'@'$SERVER' -s "'$SUBJECT'" '$NUMBER'@'$CDOMAIN
} & disown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment