Skip to main content

Free SMS from your terminal REBOOT

i have gained some (litlte)knowledge with python..

i'm on my semester holidays.. so i had some time to dance with that snake.
since way2sms perl script is not working to send sms, because they
rapidly modifying there site.

so i have planned to test my skills with python

by using only mechanize module i have done this.

i have written this code which automate the processes of sending message from indyarocks.

functions much similar the script i previously posted.

read the README file in my repo.

before that install mechanize module by

sudo apt-get install python-mechanize

or install it from software center.

fork it if you interested to improve that script

at first you have to register with indyarocks to send sms

then fill your username and password in it.

then start texting to your friends..


i have hosted the source code on github.



https://github.com/manimaran990/indsms


#!/usr/bin/python
import mechanize
import cookielib
import sys
br=mechanize.Browser()
cj=cookielib.LWPCookieJar()
br.set_cookiejar(cj)
br.set_handle_robots(False)
br.addheaders=[('User-agent','Mozilla/5.0 (X11; U; Linux i686; en-US, rv:1.9.01) Gecko/2008071615 Fedora/16.0.1-1.fc9 Firefox/17=18.0.1')]

def gettxt():
    print "enter your message : "
    txt=""
    while True:
        line=str(raw_input())
        if "$" in line:
            break
        else:
            txt+=line+'\n'
    return txt

def loginsite():
    print '>>> pls wait...'
    br.open('http://indyarocks.com/login')
    br.select_form(nr=0)
    br.form['LoginForm[username]']=your user name
    br.form['LoginForm[password]']=your password
    br.submit()
    if 'profile' in br.geturl():
        print 'login successfully'
    else:
        print 'failed to login'

def sendsms(mno,msg):
    print '>>> sending...'
    br.open('http://www.indyarocks.com/send-free-sms')
    br.select_form(nr=1)
    br.form['FreeSms[mobile]']=mno
    br.form['FreeSms[post_message]']=msg
    br.submit()
    if 'login' in br.geturl():
        print 'failed'
    else:
        print '>>> sent'

def groupsms(book,txt):
    loginsite()
    f=open(book)
    for line in f.readlines():
        mno=line.split()[1]
        print 'sending to : '+line.split()[0]
        sendsms(mno,txt)
    print 'done'

def logoutsite():
    br.open('http://www.indyarocks.com/logout')
    print 'logout successfully'
    sys.exit()


def main():
    if len(sys.argv[:])==1:
            print '''
************************************
usage :

./indsms.py mobileno
or
./indsms.py file.txt

press '$' to terminate the input message
************************************
'''
            sys.exit()
    if '.txt' in sys.argv[1]:
        msg=gettxt()
        groupsms(sys.argv[1],msg)
        logoutsite()
    else:
        msg=gettxt()
        loginsite()
        sendsms(sys.argv[1],msg)
        logoutsite()

if __name__=='__main__':
    try:
        main()
    except KeyboardInterrupt:
        print 'aborted by you'


if you have any queries feel free to ask me..

Comments

Popular posts from this blog

ARP/RARP full simulation program

server.c #include "stdio.h" #include "stdlib.h" #include "string.h" #include "sys/types.h" #include "sys/socket.h" #include "arpa/inet.h" #include "netinet/in.h" #define SA struct sockaddr struct IPmac { char ip[100]; char mac[100]; }; int main() { int sockfd,len,i; struct sockaddr_in servaddr; char buff[30],temp[30],ip[30],mac[30];

Configure opendns in ubuntu 12.04

Today i have changed my dns server name to opendns. which is alternative to default dns and it provide more secure, faster browsing experience. What is opendns? OpenDNS is the leading provider of Internet security and DNS services Industry leading malware and botnet protection Award winning Web filtering Faster, reliable, more secure DNS Ultra-reliable, globally distributed cloud network Simple, Smart, Easy How to configure opendns in ubuntu 12.04: open terminal and type sudo nano /etc/resolv.conf enter your password and change these lines   nameserver 208.67.222.222  nameserver 208.67.220.220 to use google public dns use 8.8.8.8, 8.8.4.4 instead of 208.67.222.222, 208.67.220.220 simple isn't..! now see your facebook load faster than before. opendns comes with parental control, so never worry about unwanted websites, and your childrens are safe now. to check your dns changed successfully goto welcome.opendns.com

Given a string, reverse only vowels in it; leaving rest of the string as it is

/* Given a string, reverse only vowels in it; leaving rest of the string as it is. Input : abcdef Output : ebcdaf */ import java.io.*; import java.util.*; public class VowelReverse { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); String vowels = ""; String ans = ""; int arr[] = new int[str.length()]; for(int i=0;i<str.length();i++) { if(str.charAt(i)=='a' || str.charAt(i)=='e' || str.charAt(i)=='i' || str.charAt(i)=='o' || str.charAt(i)=='u') { vowels+=str.charAt(i); arr[i]=1; } } String revVowels = new StringBuffer(vowels).reverse().toString(); int j=0; for(int i=0;i<str.length();i++) { if(arr[i]!=1) { ans+=str.charAt(i); } else { ans+=revVowels.charAt(j); j++; } } System.out.println(ans); } }