This post is the combination of all of the WebSMS scripts that I have posted to this date. This script will enable you to send text messages to Dhiraagu mobiles numbers via their websms site. As of the latest iteration, the script takes two arguments, the number (or alias) and the message.
but before that some setup notes for the n00bs
from then on you can simply run it by typing "sms [number|alias] message" on the terminal
for historical reasons, and because some people may prefer the older versions, they are included below.
and of course the first ever version of it, unbloated simplicity in itself.
but before that some setup notes for the n00bs
1) Save the script on your desktop, name it FILE (whatever you like)
2) Open up a terminal:
3) sudo cp ~/Desktop/FILE /usr/local/bin/sms
4) sudo chmod a+x /usr/local/bin/sms
from then on you can simply run it by typing "sms [number|alias] message" on the terminal
#!/bin/bash
user=YOUR-USERNAME
pass=YOUR-PASSWORD
number=$1
msg=$2
case "${number}" in
#--BEGIN DIRECTORY SEGMENT--##
hotchick1) number=7811223;;
hotchick2) number=7620382;;
hotchick3) number=7923423;;
#--END OF DIRECTORY SEGMENT--##
*)
if [ -z `echo ${number} | grep -E "^7[5-9][0-9]{5}$"` ]
then
echo "ERROR: Number not valid"
exit
fi
;;
esac
cd $HOME
echo -e "\nSending to ${number}\nMessage is `expr length "${msg}"` characters long"
if [ `expr length "${msg}"` -gt 140 ]
then
echo "Message will be truncated at ...${msg:130:10}"
fi
echo "Authenticating ... Getting cookie"
if [ -n "`curl -s --compressed -c cookiejar -d \"username=${user}&password=${pass}\" \
http://websms.dhimobile.com.mv/cgi-bin/websms/index.pl | \
sed -n \"s/.*\( 0 more \).*/\1/p\"`" ]
then
echo "ERROR: Daily quota reached"
exit
fi
echo "Attempting to send message... "
curl -s --compressed -b cookiejar -d "mobilenumber=${number}&message=${msg:0:140}" \
http://websms.dhimobile.com.mv/cgi-bin/websms/send_message.pl | \
sed -n 's/.*\([yY]ou .* Day\).*/\1/p'
echo -e "Done!\n"
rm cookiejar
for historical reasons, and because some people may prefer the older versions, they are included below.
#!/bin/bash
cd $HOME
user=$1
pass=$2
number=$3
msg=$4
echo -e "\nAuthenticating ... Getting cookie"
if [ -n "`curl -s --compressed -c cookiejar -d \"username=${user}&password=${pass}\" \
http://websms.dhimobile.com.mv/cgi-bin/websms/index.pl | \
sed -n \"s/.*\( 0 more \).*/\1/p\"`" ]
then
echo "Shit! You've hit that quota."
exit
fi
echo "Message is `expr length "${msg}"` characters long"
if [ `expr length "${msg}"` -gt 140 ]
then
echo "Message will be truncated"
fi
echo "Attempting to send message... "
curl -s --compressed -b cookiejar -d "mobilenumber=${number}&message=${msg:0:140}" \
http://websms.dhimobile.com.mv/cgi-bin/websms/send_message.pl | \
sed -n 's/.*\([yY]ou .* Day\).*/\1/p'
echo -e "Done!\n"
rm cookiejar
and of course the first ever version of it, unbloated simplicity in itself.
#!/bin/bash
#usage "./websms username password number message"
cd $HOME
curl --progress-bar -c cookiejar -d "username=${1}&password=${2}" \
http://websms.dhimobile.com.mv/cgi-bin/websms/index.pl | grep -i "day" | \
sed -e 's/<[^>]*>//g;s/^[ \t]*//'
curl --progress-bar -b cookiejar -d "mobilenumber=${3}&message=${4}" \
http://websms.dhimobile.com.mv/cgi-bin/websms/send_message.pl | grep -i "day" | \
sed -e 's/<[^>]*>//g;s/^[ \t]*//'
rm cookiejar
0 Comments:
Post a Comment