Difference between revisions of "Telenor SMS"
From ivc wiki
Jump to navigationJump to search
Line 3: | Line 3: | ||
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. | 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 | == Telenor Norway == | ||
=== 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. | 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. | ||
Line 76: | Line 78: | ||
Save it as ''telenor_send_sms.sh'' and make it executable, ''chmod +x telenor_send_sms.sh''. | Save it as ''telenor_send_sms.sh'' and make it executable, ''chmod +x telenor_send_sms.sh''. | ||
== Telenor Sweden == | |||
Anton Johansson sent me a modified version for Telenor Sweden. Just minor adjustments had to be made. | |||
#!/bin/sh | |||
# | |||
# Telenor Send SMS Script - by ivc | |||
# | |||
# 2009-02-03: Initial version | |||
# | |||
# Settings | |||
username= | |||
password= | |||
debug=false | |||
# Rest of the script, no editing needed | |||
tonumber=$1 | |||
message=`echo $@|sed -e 's/'"$tonumber"' //g' -e 's/ /%20/g'` | |||
cwd=`dirname $0` | |||
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 | |||
echo -e " Logging in..." | |||
login=`wget --quiet --no-check-certificate -O- --save-cookies=$cookiesfile --keep-session-cookies \ | |||
--post-data="msisdn=$username&password=$password" https://minasidor.telenor.se/app/minasidor/jsp/web/action.jsp?sId=VFLIVE` | |||
if [ $debug == true ]; then echo "$login"; fi | |||
loginsuccessful=`echo $login|grep "Logga ut"` | |||
toomanyattempt=`echo $login|grep "nger och har blivit utel"` | |||
if [ -n "$loginsuccessful" ]; then echo -e " Successfully logged in."; | |||
elif [ -n "$toomanyattempt" ]; then echo -e " Server reports too many failed attempts, you need to change your password manually.\n"; exit; | |||
else echo -e " Failed to log in, check the username and password!\n"; exit; fi | |||
# Send SMS -O- --quiet | |||
echo -e " Sending message..." | |||
sendsms=`wget -O- --quiet --load-cookies=$cookiesfile --keep-session-cookies --no-check-certificate \ | |||
--post-data="currentBtn=mainSendButton&comingFromMain=true&singleName=$tonumber&smsText=$message&endPhrase=" https://minasidor.telenor.se/app/minasidor/sms/send.do` | |||
if [ $debug == true ]; then echo "$sendsms"; fi | |||
sendsmssuccessful=`echo $sendsms|grep "Dina SMS har skickats till"` | |||
if [ -n "$sendsmssuccessful" ]; then echo -e " Message sent!"; else echo -e " Failed to send message, try again later.\n"; fi | |||
# SMS left count | |||
smsleft=`wget --quiet -O- --load-cookies=$cookiesfile --no-check-certificate --keep-session-cookies https://minasidor.telenor.se/app/minasidor/sms/main.do` | |||
if [ $debug == true ]; then echo "$smsleft"; fi | |||
smsleftcount=`echo $smsleft|awk -F"skickat <b>" '{print $2}'|sed 's/<\/b>/ /g'|cut -d" " -f1` | |||
if [ -n "$smsleftcount" ]; then echo -e "\n You have sent: $smsleftcount messages this month.\n"; fi | |||
# Delete cookies file | |||
rm -f "$cookiesfile" | |||
== References == | == References == |
Revision as of 14:25, 18 March 2009
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.
Telenor Norway
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 # # 2009-02-03: Initial version # # Settings username=<your telenor cellnumber> password=<account password> debug=false # Rest of the script, no editing needed tonumber=$1 message=`echo $@|sed -e 's/'"$tonumber"' //g' -e 's/ /%20/g'` cwd=`dirname $0` cookiesfile=$cwd/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 echo -e " Logging in..." login=`wget --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 echo -e " Sending message..." sendsms=`wget --quiet -O- --load-cookies=$cookiesfile --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 "Meldingen er sendt"` if [ -n "$sendsmssuccessful" ]; then echo -e " Message sent!"; else echo -e " Failed to send message, try again later.\n"; exit; fi # SMS left count smsleft=`wget --quiet -O- --load-cookies=$cookiesfile --keep-session-cookies https://telenormobil.no/ums/compose/sms.do` if [ $debug == true ]; then echo "$smsleft"; fi smsleftcount=`echo $smsleft|awk -F"web: " '{print $2}'|sed 's/<br\/>/ /g'|cut -d" " -f1` if [ -n "$smsleftcount" ]; then echo -e "\n Number of free web SMS messages left: $smsleftcount\n"; fi # Delete cookies file rm -f "$cookiefile"
Save it as telenor_send_sms.sh and make it executable, chmod +x telenor_send_sms.sh.
Telenor Sweden
Anton Johansson sent me a modified version for Telenor Sweden. Just minor adjustments had to be made.
#!/bin/sh # # Telenor Send SMS Script - by ivc # # 2009-02-03: Initial version # # Settings username= password= debug=false # Rest of the script, no editing needed tonumber=$1 message=`echo $@|sed -e 's/'"$tonumber"' //g' -e 's/ /%20/g'` cwd=`dirname $0` 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 echo -e " Logging in..." login=`wget --quiet --no-check-certificate -O- --save-cookies=$cookiesfile --keep-session-cookies \ --post-data="msisdn=$username&password=$password" https://minasidor.telenor.se/app/minasidor/jsp/web/action.jsp?sId=VFLIVE` if [ $debug == true ]; then echo "$login"; fi loginsuccessful=`echo $login|grep "Logga ut"` toomanyattempt=`echo $login|grep "nger och har blivit utel"` if [ -n "$loginsuccessful" ]; then echo -e " Successfully logged in."; elif [ -n "$toomanyattempt" ]; then echo -e " Server reports too many failed attempts, you need to change your password manually.\n"; exit; else echo -e " Failed to log in, check the username and password!\n"; exit; fi # Send SMS -O- --quiet echo -e " Sending message..." sendsms=`wget -O- --quiet --load-cookies=$cookiesfile --keep-session-cookies --no-check-certificate \ --post-data="currentBtn=mainSendButton&comingFromMain=true&singleName=$tonumber&smsText=$message&endPhrase=" https://minasidor.telenor.se/app/minasidor/sms/send.do` if [ $debug == true ]; then echo "$sendsms"; fi sendsmssuccessful=`echo $sendsms|grep "Dina SMS har skickats till"` if [ -n "$sendsmssuccessful" ]; then echo -e " Message sent!"; else echo -e " Failed to send message, try again later.\n"; fi # SMS left count smsleft=`wget --quiet -O- --load-cookies=$cookiesfile --no-check-certificate --keep-session-cookies https://minasidor.telenor.se/app/minasidor/sms/main.do` if [ $debug == true ]; then echo "$smsleft"; fi smsleftcount=`echo $smsleft|awk -F"skickat " '{print $2}'|sed 's/<\/b>/ /g'|cut -d" " -f1` if [ -n "$smsleftcount" ]; then echo -e "\n You have sent: $smsleftcount messages this month.\n"; fi # Delete cookies file rm -f "$cookiesfile"