#!/bin/bash ################################## # This script is created by D1N0 # # for free users who want to # # get notifications by SMS # ################################## ################ #INITIALISATION# ################ mode='command' # Variables USER=********** PASS=********** cols=`tput cols` lines=`tput lines` color=0 bold=0 echap() { # Escape sequence if [ $mode = 'interactive' ]; then tput rmcup || clear fi exit 0 } trap "echap" SIGINT # Ctrl+C redirection sendSMS() { # SMS sending process envoi=$(curl -i --insecure "[smsapi.free-mobile.fr]; 2>&1) retour_HTTP=$(echo "$envoi" | awk '/HTTP/ {print $2}') case $retour_HTTP in 200) echo "The message is successfully sended.";; 400) echo "No message specified; please enter a message.";; 402) echo "Too much SMS were sended in the same time; please try later.";; 403) echo "The SMS notification's service isn't enabled; please enable it.";; 500) echo "Server error; please try later." esac } ###### #MAIN# ###### while [[ $color = 0 && $bold = 0 ]]; do # Color choice color=$((RANDOM%8)) tput setaf $color bold=$((RANDOM%2)) if [ $bold = 1 ]; then tput bold fi done if [ $# -ge 1 ]; then # Command mode if [ $# = 1 ] && [ $1 = '-h' ]; then echo 'Syntax: ./sms.sh [MESSAGE] : send [MESSAGE] by SMS' echo ' ./sms.sh -h : display this help' else MSG=$* sendSMS fi else # Interface mode mode='interactive' tput smcup clear tput cup $((($lines/2)-6)) 0 figlet -cf big -w $cols sms tput cup $((($lines/2)+4)) $(($cols/4)) read MSG mode='command' tput rmcup || clear sendSMS fi echap