Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Script gia apostolh sms mesw cool4u.otenet.gr ?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Greek
View previous topic :: View next topic  
Author Message
zen_guerrilla
Guru
Guru


Joined: 18 Apr 2002
Posts: 343
Location: Greece

PostPosted: Wed Apr 19, 2006 4:00 pm    Post subject: Script gia apostolh sms mesw cool4u.otenet.gr ? Reply with quote

Hello,
3ereis kaneis an yparxei kanena scriptaki gia na stelneis sms mesw cool4u.otenet.gr ?
Exw syndesh otenet k 9a me voleve poly na xrhsimopoiousa kati tetoio stous server mou.

TIA
Back to top
View user's profile Send private message
atma
n00b
n00b


Joined: 22 Sep 2006
Posts: 13
Location: Greece, Drama

PostPosted: Fri Oct 27, 2006 8:20 am    Post subject: pezei Reply with quote

Ma yparxoun eidikes thires (gateway) gia na pejei kapio programa? Giati programmata gia na stileis sms yparxoun apo pallia alla prepei na exeis (sinithos sindromi) se kapio gateway.
Ektos apo to web-inteface loipon prosferei kai gateway gia sms to cool4you?
_________________
I like Apples!
Back to top
View user's profile Send private message
atma
n00b
n00b


Joined: 22 Sep 2006
Posts: 13
Location: Greece, Drama

PostPosted: Sun Mar 11, 2007 1:19 am    Post subject: Script for cool4u Reply with quote

πρώτα κάνε ένα "emerge mechanize" και μετά με αυτό το script είσαι έτοιμμος..
Code:

OSX atma ~/Documents $ cat cool4u.py
#!/usr/bin/env python
#
# cool4u v0.1
# Dependencies : mechanize
# Simple script to send sms via cool4u web2sms service from otenet
#
# Author: Gregory Potamianos <gregpuppy@gmail.com>
# Published under the GPL v2 :P
#

from mechanize import Browser
import sys,signal

otenet = Browser()

def login(user,password):
        otenet.open("http://tools.otenet.gr/tools/index.do")
        otenet.select_form(name="loginform")
        otenet["username"] = user
        otenet["password"] = password
        print "\nLogging in..."
        otenet.submit()

def sendsms(number,message):
        otenet.open("http://tools.otenet.gr/tools/tiles/web2sms.do?showPage=smsSend&mnu=smenu23")
        try:
                otenet.select_form(name="sendform")
        except:
                print "An Error occured. Probably Wrong Username/Password"
                sys.exit(1)

        otenet["phone"] = number
        otenet["message"] = message
        exceeded = len( otenet["message"] ) - (155 - len( otenet["email"] ))
        print "Submiting Request..."
        if exceeded > 0 :
                print "\nYou exceeded the available characters by %d\n" % (exceeded)
                sys.exit(exceeded)
        otenet.submit()
        print "Message Sent"


if __name__ == '__main__' :

        def handler(*args):
                print "\n\nBye Bye!"
                sys.exit(0)


        signal.signal(signal.SIGINT,handler)

        if len(sys.argv) == 1 :
                user = raw_input("Username : ")
                passwd = raw_input("Password : ")
                login(user,passwd)

                number = raw_input("Phone Number : ")
                msg = raw_input("SMS Message : ")
                sendsms(number,msg)
        else :
                if len(sys.argv) != 5 :
                        print "\nWrong Number of Parameters."
                        print "Usage %s <username> <password> <number> <sms>" % (sys.argv[0])
                        print "or user the interactive interface."
                else :
                        login(sys.argv[1],sys.argv[2])
                        sendsms(sys.argv[3],sys.argv[4])

OSX atma ~/Documents $

_________________
I like Apples!
Back to top
View user's profile Send private message
zen_guerrilla
Guru
Guru


Joined: 18 Apr 2002
Posts: 343
Location: Greece

PostPosted: Sun Mar 11, 2007 2:22 pm    Post subject: Reply with quote

atma: το script δουλεύει. Thanks ! :mrgreen:
Back to top
View user's profile Send private message
manos
n00b
n00b


Joined: 10 Apr 2005
Posts: 12
Location: Greece

PostPosted: Tue Mar 13, 2007 2:51 am    Post subject: Script for cool4u (πρόβλημα και λύση) Reply with quote

Δυστυχώς δεν υπάρχει πακέτο mechanize στο portage.
(Υπάρχουν τα πακέτα Test-WWW-Mechanize WWW-Mechanize-FormFiller και WWW-Mechanize στην κατηγορία dev-perl.)
Χρειαζόμαστε όμως το module mechanize για python που εγώ προσωπικά δεν είχα και έπαιρνα το μήνυμα:
Code:
$ python2.4 cool4u.py
Traceback (most recent call last):
  File "cool4u.py", line 11, in ?
    from mechanize import Browser
ImportError: No module named mechanize

Για να το λύσω αυτό έκανα τα παρακάτω:
Κατέβασα το "Easy Install" http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install και το έτρεξα ως root:
Code:
#wget http://peak.telecommunity.com/dist/ez_setup.py
#python2.4 ez_setup.py

Αφού έγινε η εγκατάσταση, για να εγκαταστήσω το ζητούμενο module έτρεξα:
Code:
 #easy_install mechanize

όπως γράφει στη σελίδα http://wwwsearch.sourceforge.net/mechanize/, στην παράγραφο Getting mechanize - EasyInstall / setuptools

Μετά από αυτά, το script έτρεξε κανονικά..
Ευχαριστώ atma :D

Ίσως το μόνο που μένει είναι να μην αφήνει τον χρήστη να γράψει πάνω από τους επιτρεπτούς χαρακτήρες αντί να δίνει:
Code:
You exceeded the available characters by ...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Greek All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum