Wednesday, August 20, 2008

Send sms Bash script

Save the following script in /usr/bin/sms and make it executable (chmod +x /usr/bin/sms)

then type sms in your terminal...

To find the user_id s, log in to wow.lk sms account once, and go send sms mode and read source code. You will be able to find the id for the users you have added to your wow-sms account. Then include those in user_id1, user_id2, and so on in the script.


#!/bin/bash
# Copyright (C) 2008 Nayanajit Mahendra Laxaman mail: nmlaxaman@gmail.com

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

RECIEVER=""
MESSEGE=""
ACCOUNT=""
ACC=""
RES=""
INFO=false
COOKEY=""

USER=
PASSWORD=

PROXY=":"

user1=user_id1
user2=user_id2
user3=user_id3


# Show usage if necessary
function usage(){
echo "Usage: $0 -r [reciever] -u [username] -p [password] -x [proxy] -m [message]-i ";
echo "";
echo "[reciever] = name of the reciever as in suntel sms account";
echo "[message] = Text of message you want to send with 140 letters";
# echo "[account] = you can have multiple accounts to wow site";
echo "[username] = Username to login wow site";
echo "[password] = Password to login wow site";
echo "[proxy] = Your web proxy in <ip>:<port> format (default:192.248.16.90:3128)";
echo "-i = Show information of the accounts and senders";
exit 1;
}

if [ $# -eq 0 ]; then
usage;
fi

#Show senders and accounts information
function info(){
echo "Reciever:"
echo "<No.> <Name>"
echo "
r1 user1(name)
r2 user2(name)
r3 user2(name)
"
exit;
}

# Get command line arguments
while [ "$1" != "" ] ; do
case $1
in
-r)
# Get the SMS number that we should send message to
RECIEVER=$2;
shift 2;
;;
-m)
# Get the message we should send
MESSEGE=$2;
shift 2;
;;
-a)
# Get the account
ACCOUNT=$2;
shift 2;
;;
-u)
# Get username
USER=$2;
shift 2;
;;
-p)
# Get password
PASSWORD=$2;
shift 2;
;;
-x)
# Get password
PROXY=$2;
shift 2;
;;
-i)
# Show information
INFO=true;
shift 1;
;;
*)
echo "Unknown option: $1"
usage;
;;
esac
done






if [[ $INFO == true ]]; then
info;
fi


ACC="Username=$USER&Password=$PASSWORD"
COOKEY="$HOME/.sms/cookey.$USER"

case $RECIEVER in
r1)
RES=$user1
;;
r2)
RES=$user2
;;
r3)
RES=$user3
;;
*)
info;
;;
esac


function debug(){
echo "curl -x $PROXY --cookie $COOKEY --cookie-jar $COOKEY --user-agent Mozilla/4.0 --data $ACC&Submit=Submit&Action=login http://sms.wow.lk/user/login.php"
echo "curl -x $PROXY --cookie $COOKEY --user-agent Mozilla/4.0 --data message=$MESSEGE&action=send&Submit=Send+SMS&$RES=$RES http://sms.wow.lk/user/sendmessages.php"
}


function sendSms(){
curl -x $PROXY --cookie $COOKEY --cookie-jar $COOKEY --user-agent Mozilla/4.0 --data "$ACC&Submit=Submit&Action=login" http://sms.wow.lk/user/login.php >/dev/null
curl -x $PROXY --cookie $COOKEY --user-agent Mozilla/4.0 --data "message=$MESSEGE&action=send&Submit=Send+SMS&$RES=$RES" http://sms.wow.lk/user/sendmessages.php >/dev/null
}



if [[ $MESSEGE != "" && $ACC != "" && $RES != "" && $PROXY != "" && $COOKEY != "" ]]; then
# debug;
sendSms;
else
echo "Check your parameters!!"
fi


Blogged with the Flock Browser

4 comments:

  1. i want to ask about this script.is it this script use mac address of the mobile phone send message or use telephone no

    ReplyDelete
  2. I don't think that this is a good method to receive server status via SMS as there is a daily limit. Is there a method to override that?

    ReplyDelete
  3. This script will not use any telephone number or a mac address. You just have to create an account at wow.lk thats all...

    ReplyDelete
  4. It is possible to create multiple accounts in wow.lk site site so it is possible to send many SMSs daily. But the good thing is, this can be use to alarm you at a critical moment.

    ReplyDelete

Intel Corporation XMM7360 LTE Advanced Modem in ArchLinux

The required packages are available in ArchLinux User Repository (AUR) so it will be easier if you can use an AUR helper package like yay . ...