Accurately Track Your Dynamic IP With Text Messages

A few weeks ago, I posted about how to send SMS messages via command line. Today, as promised, I am going to follow up on that post by providing a practical use for this functionality.

My current setup at home includes a hole in my firewall to allow SSH access to a machine sitting inside of the network. On this machine sit various items that may be useful to me when traveling outside of my home network, including movies, music, and various other files. However, this open SSH hole does me zero good if I don’t know what my machine’s IP is, and I generally would not know since the IP is dynamically allocated by my ISP.

In order to always know where my machine is currently located, it needs to phone home every time the allocated IP changes. In this case, I mean to phone home literally. I have setup this particular machine to regularly check its IP, then, if the IP has changed since it last checked, it will send me a text message with the new IP.

Continue reading “Accurately Track Your Dynamic IP With Text Messages”

SMS On Command Line

I ❤ SMSSometimes we as tech nerds like to do things just because we can. This is an example of exactly that. In an age where practically everyone who hasn’t been under a rock for the past decade has a smartphone which can send and receive email messages, putting in the work to allow sending old-school SMS messages, which are notoriously unreliable, from the command line is simply unnecessary. That said, it’s fun so I did it (and you can too)!

The first step you will need to take before starting is to make an account with Google Voice. Although you could also rely on an SMS gateways to handle text relay, this would first require knowing the cell provider that a number is tied to, which is often not practical.

In any event, once you have your account setup with Google Voice, the next step is to chose a language to write your SMS messaging script in. Although Google has never taken the trouble to release an official API for their messaging service, some smart individuals have figured it out and written libraries in a number of different languages. I personally chose to work in Perl and thus used WebService::Google::Voice::SendSMS, located in CPAN, but there are many other options, even other Perl libraries. A quick search for “<your chosen language> Google Voice” should return an option or two (and if not, why not write it?).

My solution for sending SMS via command line, seen at the bottom of this post, is relatively simple and leaves out some parameter checking that should probably be included for robustness, but it gets the point across. The basic idea is to first setup a config file containing your Google Voice login information in your home directory. Assuming a config file is found, the script uses the recipient’s phone number and the message to be sent, both given in the command line, to initiate the SMS message. Depending on whether the message is successfully delivered to Google or not, the program exits accordingly.

It is important to note that the program cannot determine whether the SMS message actually reached the intended recipient. This is neither a limitation of the library nor of Google Voice, but rather the SMS protocol, which cannot guarantee or verify delivery.

Continue reading “SMS On Command Line”