Archive for the ‘Terminal’ Category

Get More From Hotel Wifi

Monday, July 7th, 2008

ipod touch

Using multiple devices with paid hotel Internet access.

This weekend I used the Internet at a hotel that charged for access. I signed up using my iPod, then later tried to access the service using a laptop. The sign-on page didn’t provide a place to sign in using my name or room number - it seemed like I might be charged again if I went any further. I had never seen the particular service before, so I couldn’t tell what would happen.

I didn’t feel like calling the front desk, and chances are I wouldn’t have had much faith in whatever they told me. Sounds cold, but it’s true. The solution I found was probably faster anyway.

I assumed the hotel tracked my iPod by its MAC address. If you’re not familiar with a MAC address, it’s a unique identifier assigned to network devices like your wired Ethernet port or a wifi card. (MAC addresses are not to be confused with Macs) Some software interfaces provide a simple way to change the MAC address your device presents to the network. I didn’t see a simple way in System Preferences.

A quick Google search landed me at OS X Daily. There you’ll find the exact command to enter in Terminal to change your MAC address. You may have to tweak the command a little if you’re using multiple network interfaces on your Mac, like wired and wireless.

So, I took the MAC address of my iPod and assigned it to the laptop. I didn’t try to use both at once, and both worked just fine. As soon as the MAC was changed on the laptop it was on the Internet, without having to access any special sign-up page for the service.

At some point hotels will probably update their services to help with a situation like this, but in the meantime OS X Daily helped me out in less than two minutes. Nice.

Read

Twitter While You Sleep

Thursday, May 8th, 2008

TwitterWait until you see what a clever pun this title is. Using the sleep command in Terminal you can update your Twitter status while you’re away. Or sleeping.

Apple has jumped around a little with regards to command line scheduling tools, but the sleep command is still dead-simple to use. (Read more about scheduling with lingon and launchd here)

Suppose you have a command you want to run once, at a future time. Use sleep followed by the number of seconds to wait. Then use a semi-colon to separate the command to run at the appointed time.

sleep 30 ; command

The above example will execute command 30 seconds after you hit the return key. 3600 seconds is an hour. 86,400 seconds in each and every day.

So now you just need a command to update Twitter. The curl command comes with your Mac. Twitter Development Talk boasts the easiest way to update Twitter from the command line. Scroll down to The Easiest Way to Play Around with the Twitter API. Christopher Penn has a post on it too, but the command is cut-off on his blog.

The command should look like this:

curl -u username:password -d status=”your message here” http://twitter.com/statuses/update.xml

Enter that all on one line. It would be better to make it into a shell script. Just copy that line into a text file, maybe name it tw.sh, and replace the your message here part with $1. Then use chmod to make it executable.

Note: Don’t know how to make it executable? Read more about making a shell script. Learn even more about shell scripts: make an interactive shell script.

From there you can enter the following in the Terminal:

./tw.sh “Looking into starting my own airline…”

And you’ve updated your Twitter status.  You can make that cleaner by setting an alias for your shell script.

Finally, to have your tweet post onto Twitter hours later you could enter something like this in the Terminal:

sleep 7200; ./tw.sh “I’m sleeping” (you’ll need to leave your Mac on)

If you’re a stickler about your Twittering and want to be accurate, this is the way to go. Schedule that I’m in the shower tweet in advance. People need to know.

Dual Layer DVD+R = Fusion VM Backed Up

Monday, March 3rd, 2008

duplicate a dvdI picked up a stack of Sony DVD+R DL disks this morning in preparation for my first attempt at DL burning. The objective: Backing up my Fusion install of Windows XP onto two disks.

The XP vm is about 15 GB. I don’t back it up with Time Machine, but I have a separate volume on the Time Machine drive where a copy of the vm is kept. Now I can delete it if I feel the need. The way I use Windows doesn’t require updating the backup with something like SuperDuper. I’m just saving myself from ever enduring the install process by storing a copy.

Burning more than 8.5 GB ? Use Split.

First I dumped the vm folder into a .sparseimage file created with Disk Utility. Then I used the split command in Terminal to split the sparse image into two files. That was simple enough, apart from the annoying difference between GB and GiB.

The disks have 8.5 GB stamped on their tops. That’s the manufacturer’s way of making the capacity look bigger - using decimal notation instead of binary. OS X reported the blank disk as having 7.96GB free.

The disks burnt well, no coasters. If I ever need to restore the XP vm I can copy the files from my dvd+R dl disks and reconstitute them with the cat command. For two bucks I reclaimed 15 GB on my external drive. Not bad. That’s thirteen cents per GB compared with around twenty-five cents per GB on an external HDD.

Tree Command for Mac

Friday, February 29th, 2008

tree command for MacThis post is a follow up to Murphy’s post on retrieving a remote file by email. The method described in that post requires you to know the path of the file you’re retrieving. You can use the information in this post to auto-generate a text file with the paths to all your files. Retrieve that file and you’ll have all the information you might need.For some people the best thing about this post will be this:

find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'

Enter that line in Terminal, hit return on your keyboard, and you’re pretty close to the tree command you loved so much in Windows. (Thanks to the unix.com forums for help with the find and sed commands. ) You can copy and paste the command, or download a shell script containing it here. You’ll need to make it executable.

Murphy posted last week about how to retrieve a file by email. The catch was that you needed to know the path of the file. This screencast will show you how to generate a text file listing all your files in a tree format.If you prefer, you can use this command:

ls -R

That will also display files and folders, but the format is more conventional. Either command will accomplish our goal.

In the screencast Murphy has the find and sed command listed above inside a shell script. The output is redirected to a text file. You can retrieve that text file by email, just like you would any other file.

If you prefer, create a second Applescript like the one in this post. You could alter it to always send a hard-coded file: the file that lists all your files.

In the screencast, Murphy uses Lingon to configure launchd, which handles scheduling tasks you may have used cron for in the past.

For more information on creating a shell script and making the script executable visit this post. If you want to know more about sed (and awk) there’s a whole book to read.

Watch Now

Access Google Calendar from Terminal

Thursday, February 14th, 2008

gcalcliMurphy has been on the lookout for an easy way to use the Quick Add feature of Google Calendar, even when his calendar isn’t open in Safari or Firefox. There doesn’t seem to be a widget, but there is a Firefox plugin. Last time Murphy tried the plug-in there were some problems.

If you’re partial to the Terminal you might like gcalcli. Murphy uses gcalcli to make Quick Add entries from the tiny Terminal window he’s always got open. Simple, fast, convenient. He’s also using gcalcli with GeekTool to display calendar events right on the desktop, like the image you see above. (more…)

Watch Now