Telenor SMS
From ivc wiki
Jump to navigationJump to search
As a Telenor mobile subscriber, you have the possiblity to send SMS messages via their website. Also, for as long as I can remember, the first 30 messages each month are free.
This is a simple script I made to simplify the process. Instead of having to log-in to post a message, why not do it from the command-line.
Shell Script
The shell script utilizes wget for the web-requests and has some sanitation, error, and debugging functionality. Please feel free to alter the script and give me suggestions for improvements.
#!/bin/sh # Telenor Send SMS Script - by ivc # # Settings username=<your telenor cellnumber> password=<account password> debug=false # Reset of the script, no editing needed tonumber=$1 message=`echo $@|sed -e 's/'"$tonumber"' //g' -e 's/ /%20/g'` cookiesfile=telenor_cookies.txt echo -e "\n Telenor Send SMS Shell Script - by ivc\n"
# Some sanitation if [ -z `which wget` ]; then echo -e " wget binary is missing or is not in the path, install wget and get back to the script.\n"; exit; fi; if [ -z $1 ] || [ -z $2 ]; then echo -e " Missing arguments!\n\n Usage: $0 <number> <text message>\n E.g. $0 99933322 Hi m8, bouldering today?\n"; exit; fi # Debug mesages and setup if [ $debug == true ]; then echo " Sending message \"$message\" to number $tonumber"; fi # Login login=`wget $wget_args --quiet -O- --save-cookies=$cookiesfile --keep-session-cookies \ --post-data="j_username=$username&j_password=$password&fromweb=undefined" https://telenormobil.no/minesider/login.do` if [ $debug == true ]; then echo "$login"; fi loginsuccessful=`echo $login|grep "$username"` toomanyattempt=`echo $login|grep "sperret"` if [ -n "$loginsuccessful" ]; then echo -e " Successfully logged in..."; elif [ -n "$toomanyattempt" ]; then echo -e " Server reports too many failed attempts, try again in 30 minutes.\n"; exit; else echo -e " Failed to log in, check the username and password!\n"; exit; fi # Send SMS sendsms=`wget $wget_args --quiet -O- --load-cookies=$cookiefile --keep-session-cookies \ --post-data="toAddress=$tonumber&message=$message&b_send=Send" https://telenormobil.no/ums/compose/sms/process.do`
if [ $debug == true ]; then echo "$sendsms"; fi sendsmssuccessful=`echo $sendsms|grep "$tonumber"` if [ -n "$sendsmssuccessful" ]; then echo -e " Message sent to $tonumber!\n"; else echo -e " Failed to send message, try again later.\n"; exit; fi # Delete cookies file rm -f "$cookiefile"