Finding Your Phone, the Linux Way
Listing 1. lost.sh
#!/bin/sh
# A script to help you find your phone.
# by Daniel Bartholomew, May 2010
#
# This script is licensed under the terms of the
# GNU General Public License, version 3 or later.
# See <http://www.gnu.org/licenses/> for details.
# Some variables you need to set:
amilost="http://example.net/my-n900-is-lost.txt" # CHANGE THIS!
username="username" # the username at your ssh host
sshhost="hostname"
backupnumber="3215551212" # backup phone that can receive SMS messages
# A timestamp variable you can alter if you want to:
timestamp=$(/bin/date +%Y-%m-%d-%H.%M.%S-%Z)
# With the vars out of the way, we can begin:
# The first step is to check for the file on the webserver.
# If it exists, we collect data and send it,
# if not, we print a message and exit.
if wget --output-document=/tmp/${timestamp}.txt \
${amilost} 2>/dev/null; then
# If we're here, the file exists and the phone is lost.
# Get the current IP address and send it using the
# sendsms.py script:
/sbin/ifconfig -a \
| awk '/inet addr/ { print $2 }' \
| awk -F: '{ print $2 }' \
> /tmp/${timestamp}.ip
# sendsms.py from:
# http://talk.maemo.org/showpost.php?p=558430&postcount=57
/home/user/sendsms.py ${backupnumber} \
"$(/bin/cat /tmp/${timestamp}.ip)"
# take a picture with the front-facing camera
/usr/bin/gst-launch v4l2src \
device=/dev/video1 \
num-buffers=1 ! \
ffmpegcolorspace ! \
jpegenc ! \
filesink location=/tmp/${timestamp}.jpg
# get the location and send it
# gps.py from: http://talk.maemo.org/showthread.php?t=47301
/usr/bin/python2.5 /home/user/gps.py 2>&1 > /tmp/${timestamp}.gps
/home/user/sendsms.py ${backupnumber} \
"$(/bin/cat /tmp/${timestamp}.gps)"
# More things can be done.
# See http://wiki.maemo.org/Phone_control for
# ideas. Experiment and have fun!
# (But don't blame me if you accidentally brick your phone.)
# We've gathered the data we want, now copy everything to the sshhost
# server
# (need to have ssh-keys set up for this to work).
/usr/bin/scp -i /home/user/.ssh/id_rsa /tmp/${timestamp}.* \
${username}@${sshhost}:
# What if I want to run more commands than are listed above,
# such as making the phone vibrate or having it call me?
# The file I downloaded from the server can contain special
# commands. If the file is empty, nothing will happen.
# This probably is not the most secure thing to do, but if the
# phone really has been stolen, this will allow you to pull
# data off of it and/or brick the phone on purpose. Be careful!
# Only uncomment the following line if you know what you are doing
# and are comfortable with the consequences. I am not responsible
# if you break your phone.
#/bin/sh /tmp/${timestamp}.txt
else
# if the file on the server doesn't exist the phone is not lost:
echo "I am not lost."
fi
# That's it! We're done.
exit 0
I decided it would make the most sense to watch for three different actions:
The phone changing networks.
The keyboard being opened or closed.
Low power.
If the network changes, that probably means the phone is on the move (maybe I left it in a car). If the keyboard is opened or closed, someone is using or looking at the phone. Finally, if the phone is just sitting there, eventually the batteries will drain away (and I'd like to find the phone before all power is gone).
The three lines in dbus-scripts-settings that watch for those actions are the following:
/home/user/lost.sh * * com.nokia.icd * * * CONNECTED
/home/user/lost.sh * * org.freedesktop.Hal.Device \
Condition ButtonPressed cover
/home/user/lost.sh * * com.nokia.bme.signal battery_low
The lost.sh script is called each time one of those events occurs. The dbus-scripts Wiki page (wiki.maemo.org/DbusScripts) has more information on formatting the configuration lines.
See the lost.sh script (Listing 1) for details of what it does. One thing I found in testing is that some of the commands I can run on the command line do not work at all when called from a script by the dbus-scripts dæmon. These include the mplayer command and setting the phone to nonsilent mode. Thankfully, other commands work fine when called from the script.
The final piece of the puzzle was getting the N900 to send at least some of the data it gathered to another phone via SMS. I found a good Python script for sending SMS messages at talk.maemo.org/showpost.php?p=558430&postcount=57.
With the SMS script in place and called by the lost.sh script, all I have to do is create the special file on my Web server, and suddenly my N900 starts sending my designated backup phone (my wife's cell phone) SMS messages whenever one of the events I configured happens.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- Nice article, thanks for the
39 min 17 sec ago - I once had a better way I
6 hours 25 min ago - Not only you I too assumed
6 hours 42 min ago - another very interesting
8 hours 35 min ago - Reply to comment | Linux Journal
10 hours 29 min ago - Reply to comment | Linux Journal
17 hours 23 min ago - Reply to comment | Linux Journal
17 hours 39 min ago - Favorite (and easily brute-forced) pw's
19 hours 30 min ago - Have you tried Boxen? It's a
1 day 1 hour ago - seo services in india
1 day 5 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
how about an Andriod way?
how about an Andriod way?