The power of a GNU-empowered terminal
December 15, 2007
My father needed some help. The task at hand was to send invitation SMSes to about 200 mobile phone numbers.
The mobile numbers were in a text file like an address book with several irrelevant fields. The mobile numbers were stored in the form of ‘Mobile:<number>\n’ . We wanted only the mobile numbers, so I did a
cat <phonebookfile> | grep Mobile
and there – all the phone numbers were separated. Next, I wanted to throw away the Mobile: part and retain only the number. That was done using awk:
cat <phonebookfile> | grep Mobile | awk “BEGIN{ FS = ‘:’ } { print $2 } > listofnumbers
Next, we wanted to send an SMS to each of these numbers. I typed the SMS into some file (call it smsfile) and then connected my mobile phone to the computer and then did a
for i in `cat listofnumbers`; do cat smsfile | gnokii –sendsms $i >> gnokii-out 2>> gnokii-error; echo $i >> finishednos; done;
And that’s it! We had some trouble inbetween, and sending failed starting from the Nth number in the file. So what we repeated the command with tail -n <num> instead of cat on listofnumbers, to send it to the remaining.
That’s the power of BASH + GNU on the command line.
Entry Filed under: GNU/Linux/FOSS. Tags: AWK, BASH, GNOKII, Mass SMS.
1 Comment Add your own
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed
1.
Akarsh Simha | March 30, 2008 at 3:40 am
Here’s a better way of doing the same:
http://members.bas.org.in/kstar/sms_script
This script ensures that it doesn’t miss out numbers if there are errors, etc.