In my previous post I talk about needing a TFTP server in order to serve some files to a hardware device. This post describes how I used expect to automate the process of logging into the hardware device and issue commands that copy in a config file, commit it to the device, upgrade the firmware and finally tell the device to reset to factory defaults and reboot.

Expect is a way to programmatically work with a normally interactive process. Using expect you can write a script that telnets into a system and then issues commands based on what it “sees.” Here is the script I used, with some important values removed, to automate the process of updating a number of devices.

#!/usr/bin/expect
set timeout 300
spawn telnet 192.168.1.1
expect "login: "
send "root\n"
expect "Password: "
send "tehmagicphrase\n"
expect "# "
send "cd /tmp \n"
expect "# "
send "tftp -g -r config.ini 192.168.1.159\n"
expect "# "
send "config.sh import config.ini\n"
expect "# "
send "tftp -g -r firmware.img 192.168.1.159\n"
expect "# "
send "firmware_upgrade /tmp/firmware.img 1\n"
expect EOF

The above script was saved into a file called pushConfig.expect and set as executable using ‘chmod +x pushConfig.expect’. To run the script, I powered on the device and waited for it to be ready, once ready I issued ./pushConfig.expect to start the update process.

Using expect is fairly straightforward. The most difficult part is ensuring you correctly tell expect what to look for before sending the next command. In the script above I do the following:

set timeout 300

This tells expect to wait at least 5 minutes for matching text before continuing to the next send command. What this means, is if I tell it to send some data it’ll wait up to 5 minutes to see what is in the expect line after the send. In the case of my script the firmware upgrade could take quite a bit of time and I didn’t want it to timeout so I set the value fairly high.

The next line tells expect to start a telnet session to a remote machine and then to wait until it sees:

login: 

Once it sees that it sends the username. The script continues like this until it sees EOF. At this point expect knows that the process is now complete and it exits.

By using an expect script I was able to simply power on the hardware device and wait for it to boot. Once booted I ran the script. This saved me and a co-worker a lot of time while pushing custom configurations and upgrading the firmware on a number of devices.

Expect is capable of a lot more than I used in my example and can react differently based on what it receives back from the interactive process or even loop over a series of commands. To learn more about expect try ‘man expect’ or search your favorite search engine.

When asked how Microsoft plans to the extended battery life and instant on capabilities of the iPad Ballmer had this to say

“I think probably the things of tomorrow are best left for tomorrow and the things of today are best discussed today,” he said. “So today, I will focus on Windows Phone.”

Or in other words, “we have nothing.”

Came across this article talking about progress being made with the new Apple TV in regards to jailbreaking and adding new functionality. Jailbreaking was recently ruled as legal. I think this is a big win for consumers who want to be able to use their hardware devices for whatever they want. For example, I think it’s ridiculous that Apple is allowed to force me to join their developer program if I want to write my own iOS application for a device I own. It’s perfectly reasonable that if I want to distribute my software using their App Store platform but beyond that I should be faced with such restrictions.

Also, just because jailbreaking has been deemed legal doesn’t mean pirating software is suddenly legal as well. There are still plenty of other existing laws protecting against that. In the next few months or years I think we’ll see additional clarifications with the DMCA and jailbreaking. For example, although the iPhone was specifically mentioned in the ruling, I actually don’t think it should be ok to jailbreak an iPhone for security reasons as it pertains to the cell phone network. The iPhone is part of a bigger infrastructure that is not owned and operated by the owner of the phone and in that case it’s a lot like a business PC being connected to a business network. At the same however, such a ruling will hopefully coerce Apple into providing a toggle on the phone allowing end users to install software outside of the App Store. This would satisfy what some end users want while still protecting the security of the cellular network.

Apple’s new (2010) Apple TV unit have shipped and some have been delivered. Reviews are starting to pop-up in various places. So far reviews seem positive.

iFixit has done a tear down of the new device revealing 256MB of ram, 8GB of storage and an A4 processor. These specs show that the Apple TV is basically the 8GB iPod touch sans screen. They also find that the board has a spot that is basically ready to accept the 30 pin dock connector. I’m sure it won’t be long before some daring soul manages to get one soldered to it.

One of the bigger complaints, that is if you want to listen to most commenters on Engadget, is the lack of 1080p playback. That the Apple TV is only 720p is a complete non-argument because there simply isn’t a source of real 1080p content other than blu-ray. Stolen stuff doesn’t count. If you record over the air HDTV you’re either going to get 1080i or 720p content and there is basically no reason not to deinterlace the 1080i content into 720p since the vast majority of HDTV sets around today are going to be flat panel based. Netflix and Amazon HD streams are both 720p. In fact, the only 1080p streaming source I’m aware of is Zune marketplace on the Xbox 360 and I’m not aware of any other set top box that is allowed to stream Zune marketplace material and only costs $99.