The Weblog of Vincent Oberle - Thoughts and opinions about technology and business

Sending SMS with Skype on Linux

Skype for Linux 1.4 doesn’t support sending SMS in the User Interface yet, but the functionality is supported in the core library used in this release, thus it is possible to send SMS using the Public API.

I have added to my Skype command-line tools a little application for sending SMS. Usage is simple, call it with the phone number and the message to send:

$ ./sk_send_sms.py PHONENUMBER Hello world

Of course you need Skype credit for this to work. The tool doesn’t implement validating your phone number. This allows recipients of your SMS to see your mobile number as the sender, instead of the first 11 characters from your Skype Name. This can be done with Skype for Windows.

Update 2007-08-30: About the Initialization failed errors that some got, they are probably because “sms_sender” is not authorized to connect to Skype. First time the script is launched, Skype asks if you want to authorize it to connect to Skype. Later the authorized applications can be seen in Options => Public API. I fixed the scripts to show better error messages in this case.

Update 2007-12-12: I rewrote the script to use the Skype4Py wrapper. Hopefully this should solve the issues people have been seeing. As a bonus it should now work under Windows and Mac too (didn’t test that).

15 Responses to “Sending SMS with Skype on Linux”

  1. Jan
    June 24th, 2007 19:32
    1

    Thanks a lot for this slick piece of work!

    I am not really used to the terminal so some might find this helpfull: If you get error messages on
    $ ./sk_send_sms.py PHONENUMBER Hello world
    try
    $ sudo ./sk_send_sms.py PHONENUMBER Hello world

  2. Vincent Oberle
    June 28th, 2007 00:42
    2

    sudo means running the script as root, that should not be necessary, except if you run Skype itself as root, which is not necessary either.

  3. Jan
    July 3rd, 2007 09:07
    3

    Thanks for your reply. I’ve been using your tool quite regularly and can now say that my first comment is rubbish. The story goes as this:

    For the first couple of times I tried, I got an error message like this

    bla@blupp:~/skytools$ ./sk_send_sms.py +4412345678910 Hello world
    Traceback (most recent call last):
    File “./sk_send_sms.py”, line 187, in
    api = SkypeSMS(options.debug)
    File “./sk_send_sms.py”, line 93, in __init__
    self.api = SkypeAPI(’sms_sender’, debug)
    File “/home/bla/skytools/skype_api.py”, line 54, in __init__
    self.discover_skype(True)
    File “/home/bla/skytools/skype_api.py”, line 206, in discover_skype
    raise StandardException(’Initialization failed’)
    NameError: global name ‘StandardException’ is not defined

    When I tried sudo, it worked straight away. Now I can say it had nothing to do with sudo, but I can’t really say what the problem is. I still get this (or a similar) error message quite frequently but am unable to reproduce it at will. So sometimes I get an error 20, 30 times in a row and then it suddenly works. Sometimes it works straight away, and sometimes only after logging off and on again.

    But I still am very happy with your tool as it allows me keeping contact with a dear friend in China who does not receive texts from neither my German nor my British mobile. Thanks again!

  4. Roel
    August 1st, 2007 14:54
    4

    I tried it on my Ubuntu 7.04, but I ALWAYS get the errors Jan also had (see below), with or without sudo.
    This is what I did to install it:
    (1) Uncompress the tar.gz file to my (non-root) home directory.
    (2) ’sudo apt-get install python-xlib’ as this was missing apparently.

    Did I forget something??

    —– Output of ./sk_send_sms.py —–
    Traceback (most recent call last):
    File “./sk_send_sms.py”, line 187, in
    api = SkypeSMS(options.debug)
    File “./sk_send_sms.py”, line 93, in __init__
    self.api = SkypeAPI(’sms_sender’, debug)
    File “/home/rsl/skytools/skype_api.py”, line 54, in __init__
    self.discover_skype(True)
    File “/home/rsl/skytools/skype_api.py”, line 206, in discover_skype
    raise StandardException(’Initialization failed’)
    NameError: global name ‘StandardException’ is not defined
    ———-

  5. Vincent Oberle
    August 6th, 2007 17:37
    5

    Sometimes the script has issues connecting to the Skype client, I’m not sure why, may have to do with the xlib communication protocol used. But in my case it works most of the times, and I also use Ubuntu 7.04.

    Are you sure you use at least Skype version 1.4.0.64?

  6. Alex
    August 14th, 2007 18:00
    6

    Hi,

    The same here, with Kubuntu 7.04 the command line sender cannot connect to Skype:

    ~/skype_linux_tools$ ./sk_send_sms.py ### Hello world
    Traceback (most recent call last):
    File “./sk_send_sms.py”, line 187, in
    api = SkypeSMS(options.debug)
    File “./sk_send_sms.py”, line 93, in __init__
    self.api = SkypeAPI(’sms_sender’, debug)
    File “/home/alex/skype_linux_tools/skype_api.py”, line 54, in __init__
    self.discover_skype(True)
    File “/home/alex/skype_linux_tools/skype_api.py”, line 206, in discover_skype
    raise StandardException(’Initialization failed’)
    NameError: global name ‘StandardException’ is not defined

    Apart from python-xlib, do I need to install anything else? I’m using Skype 1.4.0.99

  7. fmatheus
    August 23rd, 2007 00:10
    7

    I have the same problem than Alex using Skype 1.4.0.99. The workaround is:

    1) go to Skype->Options->Public API and removing sms_sender.

    2) So the next time you try sent the message it will ask you again, so answer yes quickly.

    To send another, you’ll need follow these steps again!

    Maybe this help you debug this Vincent…
    btw, thanks for the nice job!

  8. joaorf
    August 25th, 2007 14:55
    8

    Good job, Vincent!
    But I also get the infamous «NameError: global name ‘StandardException’ is not defined».

    fmatheus trick works. But it is strange this workaround is necessary…

    Using Skype 1.4.0.99 with openSUSE 10.2

  9. fmatheus
    August 31st, 2007 23:37
    9

    A more easy workaround could be replace
    ’sms_sender’
    at line 93 of sk_send_sms.py with
    ’sms_sender’+`random.random()`
    remember to add
    import random
    at the begin of file.
    This way you dont have to delete sms_sender every time. Just answer yes! =)

  10. Jan
    October 30th, 2007 16:32
    10

    Thanks for the update. The only thing that confused me is that the script is called send_sms.py but at the top of this page it still states sk_send_sms.py, so first it didn’t work until I realised it had changed.

    Thanks again and all the best.

  11. Aram Hovsepyan
    November 20th, 2007 16:19
    11

    great job. any future plans to make a more complex script which can be more or less integrated with skype?

  12. Sam
    December 6th, 2007 06:21
    12

    Has anyone found a work around so you don’t have to remove send_sms from the public api allowed programs each time? I tried fmatheus tip but it alters sk_send_sms.py instead of send_sms.py. What line do I need to add the ’sms_sender’+random.random() line to? Any help much appreciated.

    Btw Great script Vincemt, Keep up the good work

  13. pickarooney
    January 1st, 2008 01:36
    13

    I have the following error and have nothing in the Public API list in Skype 2 Beta. Any tips?

    Traceback (most recent call last):
    File “./send_sms.py”, line 154, in
    api = SkypeSMS()
    File “./send_sms.py”, line 34, in __init__
    self.api.Attach() # Attach to Skype client
    File “/usr/lib/python2.5/site-packages/Skype4Py/skype.py”, line 470, in Attach
    self._API.Attach(self.Timeout, Wait)
    File “/usr/lib/python2.5/site-packages/Skype4Py/API/posix_x11.py”, line 320, in Attach
    raise ISkypeAPIError(’Skype attach timeout’)
    Skype4Py.errors.ISkypeAPIError: Skype attach timeout

  14. Stefano
    January 4th, 2008 16:10
    14

    I tried it on Fedora Core 6, with python 2.4.4 and Skype 2.0.0.27. It works fine, after installing Skype4Py 0.9.28.7 and ctypes 1.0.2.

    Great work!
    I wonder why it is not included in the official Skype release!

    Stefano

  15. Aram Hovsepyan
    August 27th, 2008 14:27
    15

    Hey Vincent,

    I have a minor issue with the script you wrote. Whenever I send an SMS message my processor usage goes to 100% until I get delivery report “All targets successfully delivered”. Any ideas how could I fix this.

    Thnx.

Leave a Reply