I do what I can

Random thoughts from Mauricio Teixeira…

Posts Tagged ‘tutorial

Email to SMS gateway in Linux

with 17 comments

Updated on Jul/03 — Works on Fedora 13, a fix minor inconsistencies.

This is another one of my “quick and dirty” tutorials. This time I will show you how to build an email to SMS gateway.

Before we continue, bare in mind that I didn’t care to document details on system security (specially in what regards to spam filtering or SELinux configuration). The idea here is to show an overview on what needs to be done to have it working. I also won’t explain how to configure an MX entry in DNS, or how to make this integrate to your current email system. The details should be polished by whoever is going to implement, depending on their environment.

Tools I have used here:

  1. A regular PC
  2. Nokia phone running Symbian OS, connected to the USB port in “PC Suite” mode
  3. Fedora 13, with Postfix (personally, I don’t like Sendmail)
  4. SMS Server Tools 3 (installed from Fedora repository, using yum)

First thing I did was installing the SMS Server Tools application, Postfix and disabling Sendmail. I did that because I think Postfix is easier to configure and maintain. If you want to do this using Sendmail, and you find your way into it, please paste the necessary configuration lines on the comments below.

# service sendmail stop
# chkconfig sendmail off
# yum install smstools postfix

The package in Fedora 13 already adds a private user for the sms system, creates the necessary directories and sets the permissions. So we just go with what we get.

Now we need to configure smstools with the minimum parameters necessary for it to run.

# vi /etc/smsd.conf
+ devices = ACM0
+ loglevel = 5
+ group = dialout
+ infofile = /var/spool/sms/smsd.running
+ [ACM0]
+ device = /dev/ttyACM0
+ incoming = no

Important notes here. The device ttyACM0 exists because when I connected the Nokia I selected the “PC Suite” mode. If you select anything different, it will create a different device, but none of them work for sending messages. If you are doing this on a different distribution other than Fedora, check which group is the owner of this device, and set it on the smstools config file, otherwise the application won’t be able to write to the device.

Great. Now we can start the application, and run a basic test. Remember the accepted phone number format: XXYY99999999, where XX is the country code, YY is the region code, and the rest is the real phone number.

# chkconfig smsd on
# service smsd start
# su smstools -c "smssend 551199999999 'This is a short test.'"
# su smstools -c "echo -e 'To: 551199999999\n\nThis is a long test.\nWith multiple lines.\n' > /var/spool/sms/outgoing/test"

At this point, you should have received two messages. If you don’t, read back and double check your settings (or look at the logs). If all works, keep reading.

The final part is to make Postfix receive the messages, and route via smstools. The script that converts from email to SMS is this:

# cp /usr/share/doc/smstools-*/email2sms /usr/local/bin/
# chmod +x /usr/local/bin/email2sms

And here is how we make Postfix deliver to the script:

# vi /etc/postfix/main.cf
+ inet_interfaces = all
+ mailbox_transport = smstools
# vi /etc/postfix/master.cf
+ smstools  unix  -       n       n       -       -       pipe
+  flags=DORhu user=smstools argv=/usr/local/bin/email2sms
# chkconfig postfix on
# service postfix start

If you don’t set the inet_interfaces option, Postfix will only accept connections from localhost. If you need it to receive messages from anywhere in your network, better put something meaningful there.

Now we need to make Postfix understand what is considered to be a valid user on the server. For that, we keep the old /etc/aliases, and add our users:

# vi /etc/aliases
+ 551199999999: netmask
+ 551188888888: badnetmask
# newlaliases

Remember: for every SMS recipient there must be an entry in /etc/aliases. The name after the colon is mandatory because of the file format, but will make no difference to the delivery system, so just use something that will identify the user of that address.

At last, test it:

$ telnet smsgateway.example.com 25
Connected to smsgateway.example.com (
Escape character is '^]'.
220 smsgateway.example.com ESMTP Postfix
helo netmask.example.com
250 smsgateway.example.com
mail from: netmask@example.com
250 2.1.0 Ok
rcpt to: 551199999999@smsgateway.example.com
250 2.1.5 Ok
354 End data with .
To: 551199999999@smsgateway.example.com
Subject: Test subject
Hello world!
250 2.0.0 Ok: queued as C52E620236

That’s it!

I hope this is useful for you. If you find any mistakes or you wish to suggest any different setup to our next readers, please feel free to comment below.

Have fun! 🙂


Written by netmask

março 11, 2010 at 11:48

Publicado em Uncategorized

Tagged with , , , ,

Convert from VirtualBox to KVM

with 7 comments

Quickest and dirtiest way to convert your VirtualBox machine into a KVM machine.

First of all, make sure you have enough space. If you have created a dynamically growth disk, the virtual disk has been defined as 20GB in size, but is only currently using 8GB, you will need 28GB extra (8 for the original file you already have + 20 for the temp file + 8 for the final file). If you’re using disks with pre-allocated size, you will need 2 times extra the space (20 original + 20 temp + 20 final, in this example).

1 – Convert the VirtualBox VDI file into a RAW image.

$ VBoxManage clonehd --format RAW MyTestVM.vdi MyTestVM.raw

2 – Convert the RAW image into a QCOW file.

$ qemu-img convert -f raw MyTestVM.raw -O qcow2 MyTestVM.img

3 – Voila. Go into virt-manager, create the machine, and use your newly created image.

Written by netmask

março 3, 2010 at 01:20

Publicado em Uncategorized

Tagged with , , ,

Utilizando o controle remoto da PixelView Play TV Pro Ultra no Fedora 12

with 2 comments

Recentemente reorganizei meu escritório em casa, e no meio disso, coloquei um sofá, para que eu pudesse assistir filmes confortavelmente (apenas uma segunda opção, já que tenho um Popcorn Hour na sala de estar). Enquanto olhava nas coisas velhas, encontrei o controle remoto que veio com minha antiga PixelView Play TV Pro Ultra, que eu não utilizo há um bom tempo, mas que está instalada do mesmo jeito. Já que eu tenho isso, decidi usar o controle remoto, para fica ainda mais confortável vendo meus filmes do sofá.

Itens utilizados nesse tutorial:

Visão rápida da instalação do hardware: espete a placa no slot PCI, conecte o receptor de infra-vermelho no pluge certo da placa, inicie o sistema. Você consegue… 🙂

Aparentemente o Fedora irá detectar a placa de TV, mas não vai reconhecer o modelo correto, portanto você precisa dizer exatamente qual placa está sendo utilizada. Você faz isso criando um arquivo que irá passar o modelo para o driver:

# cat /etc/modprobe.d/cx88xx.conf
options cx88xx card=27

Agora você tem duas opçẽos: reiniciar o sistema, ou recarregar o módulo. Para recarregar o módulo, execute os seguintes comandos:

# rmmod cx8800
# rmmod cx88xx
# modprobe cx88xx
# modprobe cx8800

Agora instale os pacotes necessários:

# yum install lirc totem-lirc

E aqui estão os passes de mágica: o controle remoto não funciona de primeira, então precisei dizer ao lirc onde encontrar o dispositivo correto, e criar um novo arquivo de configuração explicando a ele o que cada botão faz (bom, pelo menos a maioria deles).

Primeiro você precisa dizer ao lirc onde encontrar o dispositivo. Para isso edite o arquivo /etc/sysconfig/lirc e modifique-o conforme abaixo:


Em seguida salve o text desta página para um arquivo chamado /etc/lirc/lircd.conf. Agora habilite o serviço do controle remoto:

# chkconfig lirc on
# service lirc restart

Depois disso, tudo o que você precisa fazer é abrir o Totem, ir para o menu Editar -> Plug-ins e habilitar o “Controle remoto infra-vermelho”.

Infelizmente não dá para abrir um arquivo novo, nem pular para o próximo arquivo na sua lista de reprodução, mas ao menos você pode executar, parar, finalizar, adiantar ou voltar o vídeo. Talvez depois eu dedique um tempo para habilitar mais recursos do controle (ou, se você já o fez, por favor fale como nos comentários dessa página).

Divirta-se! 🙂

Written by netmask

fevereiro 14, 2010 at 21:43

Publicado em Uncategorized

Tagged with , , , , ,

Using PixelView Play TV Pro Ultra remote control on Fedora 12

leave a comment »

I recently reorganized my home office, and when doing so, I added a couch so I could watch movies more comfortable (it’s a second option, since I already have a Popcorn Hour at the living room). While looking at some old stuff, I found the remote control that came with my ancient PixelView Play TV Pro Ultra, which I don’t use for a long while, but it’s still installed anyway. Since I have that, I decided to make the RC available, so I could be even more comfortable while pausing/fast-forwarding my movies from the couch.

Items used in this tutorial:

Quick overview about the hardware install part: place the card on the PCI slot, connect the IR receiver on the proper plug on the board, boot the system. You’ll find your way… 🙂

Apparently Fedora will detect the TV card, but it won’t recognize the proper model, so you need to tell it exactly which card is in use. You do so by creating a file telling the driver about it:

# cat /etc/modprobe.d/cx88xx.conf
options cx88xx card=27

Now you have two options: reboot, or reload the module. To reload the module, run the following commands:

# rmmod cx8800
# rmmod cx88xx
# modprobe cx88xx
# modprobe cx8800

Now install the necessary packages:

# yum install lirc totem-lirc

And here are the magic tricks: this remote control does not work out of the box, so I had to tell lirc where to find the IR input device, and create a new config file to make it understand what each button does (well, at least most of them).

First you need to tell lirc where to find the IR input device. You do so by editing /etc/sysconfig/lirc and editing the device line like this:


Next, save the text of this page to a file named /etc/lirc/lircd.conf. Now enable the remote control daemon:

# chkconfig lirc on
# service lirc restart

After that, all you need to do is open Totem, go to menu Edit -> Plug-ins and enable the “Infra-red remote control” plug-in.

Unfortunately you can’t open a new file, neither skip to the next file on your play list, but at least you can play, pause, stop, fast forward and rewind. Maybe I’ll take some time later to enable more of the IR features (or, if you have done so, please add to the comments of this page).

Have fun! 🙂

Written by netmask

fevereiro 14, 2010 at 21:21

Publicado em Uncategorized

Tagged with , , , , ,

Aplicação na Área de Notificação do Gnome em Python (português)

with 4 comments

É bom ver como sua aplicação preferida no Gnome fica lá na área de notificação (também chamada de bandeja), e convenientemente fica lá até alguma coisa acontece. Você já se perguntou como se faz isso em Python?

Essa é uma demonstração não-tão-rápida e não-tão-limpa de como escrever uma pequena aplicação Gnome em Python que fica na área de notificação do Gnome (que também vamos chamar de “bandeja”), e reage a algumas ações de menu.

Você pode encontrar o código compledo baixando o arquivo hello-tray.py. Abaixo irei comentar as partes mais importantes do código, de forma que você entenda o básico, e possa criar seu próprio código daqui em diante.

Continue lendo »

Written by netmask

abril 18, 2009 at 13:31

Publicado em linux

Tagged with , , , ,

Gnome Notification Area Application in Python (English)

with 13 comments

It’s nice how many of your preferred Gnome applications can fall back into a small icon on the notification area (also called tray), and conveniently sit there until something happens. Have you ever wondered how to do that in Python?

This is a not-so-quick and not-so-dirty demonstration of how to write a small Gnome Python application that will sit in the Gnome notification area (which we will also call “tray”), and react to some menu actions.

You can find the full code by downloading this file:

Below I will comment the most important parts of the code, so that you understand the basics, and create your own code from there.

Continue lendo »

Written by netmask

abril 18, 2009 at 13:00

Publicado em linux

Tagged with , , , ,

Enabling/Disabling Compiz from command line

with 6 comments

To disable Compiz on the command line:

Red Hat -> gconftool-2 --type string --set /apps/gnome-session/rh/window_manager "metacity"
Fedora ->
gconftool-2 --type string --set /apps/gnome-session/required_components/windowmanager "metacity"

To enable:

Red Hat -> gconftool-2 --type string --set /apps/gnome-session/rh/window_manager "compiz"
Fedora ->
gconftool-2 --type string --set /apps/gnome-session/required_components/windowmanager "compiz-gtk"

Written by netmask

novembro 29, 2007 at 18:00

Publicado em linux

Tagged with ,