Flight schedules to iCal? Done!

I travel a lot (too much).  As such, my favorite airline (Southwest) has become the proverbial company bus.  Actually, that’s not really in any proverb, but you know what I mean.

Anyway, I travel often enough that the process of purchasing flights, placing them in my calendar, and scheduling the ‘Flight Status Updates’ gets a little tedious and error prone.  Apparently at one time southwest provided the option of placing the flight in a iCal file, but it went away with a recent website update. What to do?  Geek it?

Here’s my solution:

Southwest sends an email with your itinerary in a psuedo-pretty XML format when you purchase a trip.  I use procmail to filter my incoming mail and southwest.com email gets put in it’s own special ‘folder’.  I recently added a simple bash script to ‘grep’ the contents of this folder and extract relevant itinerary information.  The script is executed directly by procmail.

The output of the script is a CSV format text file that is accessible by a php script executed by apache.  This script takes the text file, munges it with some information about the airport location and DST and arrives at a starting and ending time of the flight.  This is output via iCalcreator as an iCal format file that your favorite calendar program can handle (right?)

Download here

There are a number of dependencies.  See the README file for them all

 

Linux autofs: Authenticate against different SMB servers

I work with lots of Windows machines on different Windows Domains.  I try to make use the the autofs to automagically mount them.  Herein lies an issue.  The domains require different credentials to access them.  The stock Fedora auto.smb does not have a way to provide credentials to the server.  I have modified mine as shown below to add the ability to provide credentials based on the name of the server you are trying to access:

#!/bin/bash

# This file must be executable to work! chmod 755!

key="$1"
if [ -r /etc/smb.credentials.$1 ]
then
 CREDENTIALS=/etc/smb.credentials.$1
else
 CREDENTIALS=/etc/smb.credentials
fi

opts="-fstype=cifs,credentials=$CREDENTIALS"

for P in /bin /sbin /usr/bin /usr/sbin
do
 if [ -x $P/smbclient ]
 then
 SMBCLIENT=$P/smbclient
 break
 fi
done

[ -x $SMBCLIENT ] || exit 1
$SMBCLIENT -gNL $key --authentication-file=$CREDENTIALS 2>/dev/null | awk -v key="$key" -v opts="$opts" -F'|' -- '
 BEGIN   { ORS=""; first=1 }
 /Disk/  {
 if (first)
 print opts; first=0
 dir = $2
 loc = $2
 # Enclose mount dir and location in quotes
 # Double quote "$" in location as it is special
 gsub(/\$$/, "\\$", loc);
 print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\""
 }
 END     { if (!first) print "\n"; else exit 1 }
 '

So, to access a server, I can create a /etc/smb.credentials.{servername} with appropriate username/passwords in it.  If there is more than one server in the same domain, I just use symlinks between the two files.  I guess it would be slicker if I did something like /smb/{DOMAIN}/{SERVER}/{SHARES}, but at this time, I have what I need.

I Need a Left Handed Laptop!

Yes, Dorothy, even laptops are biased towards the right handed world!

My laptop (Dell Vostro 1700) is nice enough on most accounts, it’s getting a little old, but works well enough.  There is one issue that has been annoying since I bought it:  The cooling fan and heatsink are on the left side of the computer.  My mouse goes on that side and consequently, my hand ends up in this open-air convection oven whenever I’m working on it.  It’s not as bad as some laptops, but I still notice it.