Skype4py script to send message to Skype from shell on Linux Ubuntu

This is a tiny note, that describes the way how to send messages to Skype from linux shell. I had a Linux Ubuntu 12.04 for my experiments.

This information might be useful if you’d like to make your scripts to send notifications to your Skype.

First of all you’ll need to download Skype4py library.

Unpack it and run

sudo python

Дальше нужно создать скрипт которым мы будем отправлять сообщения. Очень хорошо было бы ложить его в папку, которая входит в переменное окружение $PATH – это позволит вызывать скрипт из любого каталога системы без полного пути к нему.

Next you’ll need to create the script that will work with this library and send messages. It would be greate to locate it in the folder, that is included into the $PATHS environment. This will allow you to call the script by typing the name

You can check the $PATH with the following command:

echo $PATH

I got the following output:


Let’s grab the finst folder in the line (/usr/local/sbin) and create file in it, with the following contentns:

# This script allows to sent messages to skype
# using skype API for python

import Skype4Py import sys

client = Skype4Py.Skype() client.Attach() user = sys.argv[1] message = sys.argv[2] client.SendMessage(user, message)

The main issue here is in fact that Skype4Py works with the instance of skype the is launched and gets information from it. The client.Attach function is responsible for interaction. If you have multiple Skypes running (Skype1, Skype2), than client.Attach will catch the most recently launched instance.

And yes, you need a working Skype to use the library.

Usage example: contact_user.Handle “message”

Get my name from Skype. This approach can be used to determine the instance of Skype, that works with Skype4Py:

python -c ‘import Skype4Py; client = Skype4Py.Skype(); client.Attach(); print client.CurrentUser.FullName, “(“, client.CurrentUser.Handle, “)”‘

List contacts:

python -c ‘import Skype4Py; client = Skype4Py.Skype(); client.Attach();
for user in client.Friends: print user.Handle, “(“, user.FullName, “)”;’

Any other examples are highly appreciated in comments. It has been a long time since I used this library.

Share Button

Leave a Reply

You must be logged in to post a comment.