Zach Burlingame
Programming, Computers, and Other Notes on Technology

July, 2011Archive for

How to Get the Exit Code of a Windows Command Line Application

Friday, July 29th, 2011

Since I regularly forget the exact name and end up having to look this up, I’m documenting it here.

If you run an application from the command-line and want to get it’s exit status code, you use:
[bat gutter=”false”]

Beware however, if there is an environment variable called errorlevel, because it will override the exit code.

See this SO question for more information.

HOWTO: Enable Wireless Networking on Boot in Ubuntu Linux without NetworkManager

Monday, July 25th, 2011

Building on my previous post, this is how to enable wireless networking on boot without NetworkManager.

I’m using WPA in this example, but the setup is similar for WEP and WPA2 using wpa_supplicant.

Remove NetworkManager (Optional)

sudo apt-get remove network-manager

Setup WPA Supplicant

To convert the WPA passphrase into the appropriate form (which is salted with the SSID), you need to use wpa_passphrase. For example:

wpa_passphrase my_ssid my_secret_password



Using this information, you need to setup /etc/wpa_supplicant.conf like so:


Enable Wireless Interface

Put an entry in /etc/network/interfaces for wlan0 (or wlan1, or whatever your wireless interface is).

NOTE: I’ve put the DHCP option here for completeness, but I ran into problems with a Belkin USB F5D9050 wireless adapter not getting an IP successfully, even after it associated with the AP. I’m not sure if this was a problem with the device, the linux driver, or the AP. I ended up adding a DHCP reservation on the AP and then using a static IP configuration on the server.

Option 1: DHCP

auto wlan0
iface wlan0 inet dhcp

Option 2: Static IP

auto wlan0
iface wlan0 inet static
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf


If you are having issues getting this to work, one debugging trick is to start up wpa_supplicant directly in the foreground and checking the output of dmesg and /var/log/syslog for additional details.

sudo wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -dd

HOWTO: Enable Wired Networking on Boot in Ubuntu Linux without NetworkManager

Thursday, July 21st, 2011

A lot of Linux distros are going to applet-based management of their network connections in their desktop flavors. For example, Ubuntu Linux Desktop Edition has been using the Gnome applet NetworkManager since at least 9.10 Karmic Koala. While it works great most of the time, I’ve run into issues with it several times.

UPDATE:I believe this issue may have gone away with recent versions of NetworkManager.
The first was that (at least with 9.10) while NetworkManager was running from boot, it didn’t start receiving commands to connect until the user initiated their Gnome session by logging in. If you wanted to run an SSH server on the machine, you wouldn’t be able to connect to it until a local user logged in.

The second issue is that I often times end up using the Desktop Edition in a server-like capacity and turn gdm/X off entirely. The Desktop Edition has a shorter-lead time for package updates (which can be both a blessing and a curse). In my experience it’s also easier to find help/info on it versus the Server Edition. I recently setup a machine to act as a server for my dad, connecting to his weather station’s base station and uploading the results online. I ended up using the Desktop Edition of 11.04 because the server version didn’t have support out-of-the-box for some of his hardware.

Anyways, while I found it maddening to find a solution to initially, like many things Linux, once you know the magic incantation to recite, it’s cake.

Remove NetworkManager

This is optional and many of you may want or need to keep it around. For me, in the cases where I need to use this at all, I find it easier just to completely remove NetworkManager from the picture.

sudo apt-get remove network-manager

Enable Wired Interface

Put an entry in /etc/network/interfaces for eth0 (or eth1, or whatever your wired interface is).

Option 1: DHCP

auto eth0
iface eth0 inet dhcp

Option 2: Static IP

auto eth0
iface eth0 inet static

Now your network interface should come up on boot, without NetworkManager!

HOWTO: Disable IPv6 in Ubuntu Linux

Thursday, July 21st, 2011

Although we are edging closer to wide-spread IPv6 adoption with milestones such as World IPv6 Day, we aren’t quite there yet. Since I don’t use IPv6 on my LAN, I prefer to disable it. These instructions were written with Ubuntu 11.04, but it should work for 9.x,10.x, and probably many other distros as well.

Check if IPv6 is enabled

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

0 means IPv6 is Enabled while 1 indicates that IPv6 is Disabled

Disable IPv6

Add the following to /etc/sysctl.conf

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1


Automotive Systems to Mitigate Heat-Related Deaths or HAL9000 Rescues Timmy

Wednesday, July 6th, 2011

Recently a child in our community died when they were left in the car for several hours when the outside temperature was in excess of 80F. This tragic accident is not the first time I’ve heard of children being left in cars during temperature extremes. Unfortunately in the fast paced world we live in with hectic schedules and constant distraction, it probably won’t be the last either. There are numerous aides that parents can employ to help remind them that their young children are in the car. Establishing a routine, placing your bag or phone in front of the child’s seat, and setting reminders on your phone are just a few of the ideas that regularly come up. While technology alone cannot solve the problems of human error and distraction, this is an area that I feel it could provide significant impact.

Today’s cars are outfitted with myriad sensors and automated controls. Power windows, power door locks, alarm systems, weight sensors for airbag activation, door ajar sensors, temperature sensors for automatic climate control, and even motion or radar sensors for alarm systems in some convertibles. The equipment is present to provide several different types of solutions to the problem of children or pets being left in cars during temperature extremes.

Type I – Early Warning/Reminder Systems

The best solution is to prevent the child, pet, elderly, or disabled individual from being left in the car in the first place. Several concepts that could be applied here:

  • Unique alarm, tones, or spoken word (such as from the navigation system) reminding the driver that a rear occupant has been detected when they remove the key from the ignition.
  • Unique alarm or tones when locking the doors and/or arming the security system on a car when a rear occupant is detected. Many cars will sound a continuous tone when the owner attempts to lock the doors with the key fob if a door is ajar or the lights are left on. In much the same way, a tone could be sounded if a rear occupant is still in the car.

Type II – Notification Systems

The next class of solution is to notify others of the potential danger after certain conditions are met. For instance, trigger conditions could include such things as timers, internal temperature sensor data, rear occupant weight sensors, and/or motion sensors. When a potentially dangerous situation is detected, the car could alert others in one of the following ways:

  • Sounding a unique alarm or tone. It is imperative that this tone be easily distinguishable from the normal alarm sounds that so many of us have become immune to due to false alarms. Ideally it would be a pattern that would be agreed upon by all car manufacturers such that it would become the ‘universal signal’ for an at risk occupant locked in a car.
  • In cars equipped with remote monitoring and communication systems, such as GM’s OnStar, notifications could be sent to the owner’s email, smart phone, or even local authorities including GPS coordinates and internal temperature readings.

Type III – Risk Mitigation Systems

The final class of solution would seek to reduce the threat to the at-risk occupant. Once trigger conditions were meet, the car could respond in one or more of the following ways:

  • Opening all the windows partially
  • Turning on the car’s HVAC fan

These are just some ideas I thought of in a single sitting after hearing of this tragic story on the news. Certainly the engineers in the automotive industry who can design automatic transmissions, hybrid and plug-in power trains, integrated navigation and infotainment systems, and 100HP/L+ engines can greatly improve on this. I realize that there are significant financial, legal, and technical hurdles that must be overcome to take an idea like this into production. However, I think effective solutions can be implementing using one or more of the classes of systems above in a cost effective manner. Car manufacturers could partner with one another to offset design, component, and integration costs. Many of the necessary components are already present in modern cars thus reducing incremental costs. Finally, much like many other new and innovative systems, they could be targeted to specific vehicle classes or models (minivans, SUVs) initially and offered on higher margin trim levels and/or as additional cost options. As the systems mature and the costs come down, they could then be trickled down to other vehicles.

Keeping Applications Up-to-Date on Windows Systems

Monday, July 4th, 2011

With so many applications installed on your machine and with many of us having multiple machines, keeping them up-to-date is a real PITA and chews up a lot of time. Microsoft has helped us out a lot with automatic updates to Windows, .NET, Office, Microsoft Security Essentials, SQL Server, and several other applications. Other applications like the JRE and Adobe Acrobat Reader have added automatic application updating as well, but there are still numerous applications on most machines (a quick look at one of my machines shows over 139 applications!) that require at least manual update installations, if not manual update checks as well.

Enter Secunia’s Personal Software Inspector (PSI). Free for personal use, this application detects and installs missing security patches for hundreds of different Windows applications. For many applications it can offer to install the updates automatically and when it can’t, it can link you directly to where you need to go to get the update. If there is an application that isn’t currently supported by PSI, it’s very easy to submit a request to Secunia to have it added by clicking the “Are you missing a program?” link on the “Scan Results” page.

PSI gives you a nice dashboard with some historical “Secunia Score” tracking.

Secunia Dashboard

Secunia PSI Dashboard

The meat of the application is the “Scan Results” page which shows you a list of applications you have installed that it can monitor, the current version you have installed, whether it’s up-to-date or not, and where the application is installed.

Secunia Scan Results

Secunia PSI Scan Results

Occasionally I have to go in and manually remove an old instance of an application (old JDK version, Google Chrome instances, etc.) to get the patch level to 100%, even though I’m only using the latest version. I’ve been running this on several of my machines for close to a year now, and overall I’ve found it to be a real time saver.

Windows Updates for Offline Machines or Slow Connections

Friday, July 1st, 2011

I needed to upgrade someones computer to Windows 7 and they had a very slow internet connection. To save time, I wanted to download all of the updates ahead of time so I wouldn’t have to wait an eternity for them when I was on-site. I initially considered setting up a WSUS server inside a VM but stumbled across another solution in the process: WSUS Offline Update.

I simply downloaded and extracted the zip file to an external hard drive, ran UpdateGenerator.exe, selected the products I wanted and then let it eat overnight to download all the packages. I then took the external hard drive with me, attached it to the machine after I installed the OS, ran the UpdaterInstaller.exe (located in the client directory) and in very short order had (almost) all the Microsoft Windows, .NET, VC++ Redistributable, and Office updates installed. On a Windows 7 Professional x86 machine, Windows Update still found about 18 packages totaling 38MB that needed to be downloaded after WSUS Offline Update had done its thing. Not perfect but sure beats downloading a gig+ over a slow connection.

I’ve also used the app to update new VMs when I create them, as it’s still faster getting them off the disk than the internet, even with a fast connection.