short introduction to [wg]ammu
SMS from your laptop? It’s more likely than you think!
A mighty program enbles you to connect your computer with your phone and use it’s functions without having to mess with the tiny keys.
The last hackathon I attended my resolutions weren’t overwhelming: sort my stuff and play around with led matrices. But right in the middle of slacking I remembered a program I installed a week earlier: [WG]ammu. It’s in fact a bundle of stuff:
There’s Wammu, a nice GUIded programm to interact with one’s phone. Backup messages, Contacts and even send SMS with it (Usual fees apply). It has a well guided wizard to set up your phone with bluetooth or data cable and handled my Sony Ericsson K530i pretty well. Flawlessly even, as a fellow Hacker next to me had some problems getting SMS-sending to work with his Nokia phone.
Next one is Gammu. Almost the same, but now without the GUI. All command-line interface, it is the backbone to Wammu. Pretty awesome to read and send Messages from your command line. But why would you want that? Mostly because we can, I guess.
Last but not least is the Gammu-SMSD. The D stands for Daemon and that is where the fun begins: it runs in the background of your system and can manage you incoming/outgoing SMS through files, a database or whatever you come up with. The best part is, it has a RunOnReceive setting so that you can run a script or program when it gets a new message.
I called it a day at sunrise when my lolshield displayed the message a friend sent to my phone. One day I’ll hock it up to our thermostat for timed and remote control.
For now, here’s the story all about how..
To play around a bit, get the package via apt-get, synaptic or whatever you are using. Check the version by typing
gammu --help gammu
Wammu works fine at 1.24, but if it is below 1.27 and you want to run the SMS-daemon, get the latest install as tarball from the website. (and a handy howto for people like me who’ve grown up with packages managers)
That’s also where you should start. Wammus PhoneWizard works pretty well, make sure that your phone is connected somehow to the computer and you will find afterwards a .gammurc in a home directory that you can examine. Mine looks like this:
[gammu]
port=/dev/ttyACM0
connection=at
synchronizetime=yes
logformat=nothing
Instead of doing it manually, you can use gammu-config to change settings. There doesn’t seem to be much to it, just set the right port and connection and you are ready to test your setup in the terminal using gammu --identify. If it returns some data about your phone, you are ready to send your first sms from the command line:
echo "hello world!" | gammu-sendsms TEXT +001122334455
Make sure that you dont change TEXT to something else and to play around with the commands, as they are amazing. I don’t know about you, but I honestly imagined it harder to do this kind of stuff.
For gammu-smsd it gets a tad bit trickier. Set up a configuration file for it at /etc/gammu-smsdrc. here’s mine:
[gammu]
port = /dev/ttyACM0
connection = at
[smsd]
service = files
logfile = syslog
debuglevel = 0
inboxpath = /home/name/smsd/inbox/
outboxpath = /home/name/smsd/outbox/
sentsmspath = /home/name/smsd/sent/
errorsmspath = /home/name/smsd/error/
RunOnReceive = /home/name/scripts/alert.sh
I ran into some trouble with the default settings that save the messages in /var/spool or something, so I changed this. alert.sh contains a simple shell script with little more than xmessage "it friggin works!". Type
gammu-smsd --config /etc/gammu-smsdrc --pid /var/run/gammu-smsd.pid --daemon
to run the process as daemon. This should be straightforward. –pid saves the process id it runs under in case you need it later. It’s important to note that once gammu-smsd runs, all of the usual gammu commands won’t. You need special commands to get the SMSD sending your messages out, like
echo "Technologic" | gammu-smsd-inject TEXT +001122334455
My final setup included JPRodgers lolshield that displayed incoming messages, but it’s very dirty coding, so I won’t post it here. Leave a comment if you want to know more
I need a help dear..
I want a bash script to RunOnReceive.It should capable of executing a php file on my www folder.
Pls help me..
Regards,
-Gemunu
ගැමුණු | Gemunu
March 20, 2011 at 4:44 pm
As I haven’t heard from you I suppose the issue was resolved by making a RunOnRecive.sh like this:
#!/bin/bash
php /your/file/here.php
themoep
April 3, 2011 at 9:17 am