Mounting NFS shares on my home network

I use NetworkManager to connect to my wireless network and wanted a way to map the drives automagically when I connect.  However, as I connect to a number of wireless access points I didn’t want to send my credentials trying to find my home server out each time I connect at the coffee shop.

Enter the NetworkManager dispatcher.  Scripts in /etc/NetworkManager/dispatcher.d/  are executed when the network manager connection is made.  I created the following file as “99mountmydrives” and chmodded it with execute permissions.

See the script below:
[code]
#!/bin/sh

IF=$1
STATUS=$2
USER=myusername
SERVERIP=192.168.1.200
SERVERMAC=00:aa:bb:cc:dd:ee

echo “running 99mountmydrives as `whoami`;” >> /tmp/dispatcher-log
echo “int=$1 and status=$2” >> /tmp/dispatcher-log

wait_for_process() {
PNAME=$1
PID=`/usr/bin/pgrep $PNAME`
while [ -z “$PID” ]; do
echo “waiting.” >> /tmp/dispatcher-log
sleep 3;
PID=`/usr/bin/pgrep $PNAME`
done
}

mount_drives() {
echo “waiting for nm-applet” >> /tmp/dispatcher-log
wait_for_process nm-applet
echo “mounting drives” >> /tmp/dispatcher-log
/home/mvoorberg/automountmyth.sh
}

if [ “$IF” = “wlan0” ] && [ “$STATUS” = “up” ]; then
#WIFI Subnet at home

test=`ping -c 3 $SERVERIP >/dev/null;arp -a $SERVERIP`
echo “$test” >> /tmp/dispatcher-log

if expr “$test” : “.*$SERVERMAC” 2> /dev/null ; then
mount_drives
exit $?
fi
fi
[/code]

getElementById fails on IE

While working on a simple test page, I wanted to use getElementById to get an Image object from JavaScript.  I quickly wrote up the code and tried it.  Firefox was fine but it failed on my IE7 with “Microsoft JScript runtime error: Object doesn’t support this property or method”.  It took some digging to see what the problem was.

First thing I checked was that I used both element Name and Id and that they were the same.  I *always* do that given that IE will use whichever one matches the desired string.  After reading a few blog posts about common problems but with no good ideas I went back to my code and reviewed it carefully.  It turns out that I used the same name for my element and my local JavaScript variable.  That by itself isn’t a problem but what made it an issue for me was that I failed to initialize my variable with the “var” keyword.

See the code below for the example:
[code]





Do Something




[/code]

Lorem Ipsum

As a web developer I constantly find myself copy & pasting this text.  What better way to start a new blog, than to  use a few paragraphs of boilerplate text.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec leo nisi, tincidunt quis euismod facilisis, consequat sed est. Curabitur faucibus consequat lacus, at pretium arcu placerat a. Nulla imperdiet nunc eu dui consequat blandit. Aenean sollicitudin tempus posuere. Aliquam nec risus sapien, a lacinia nulla. Pellentesque iaculis, justo non euismod malesuada, tortor turpis ornare quam, ut bibendum sapien neque et lorem. Aliquam erat volutpat. Curabitur id ligula quis augue condimentum lobortis non id massa. Ut nisi nunc, suscipit ac dictum vel, hendrerit ut neque. Sed molestie magna sed felis ullamcorper faucibus a ut metus.

Praesent a nunc vel dolor luctus tristique. Etiam vel elit eget sem ultrices mattis non quis mi. Aliquam eget tristique libero. Etiam faucibus, metus in porta hendrerit, velit nibh posuere justo, vel molestie turpis leo sit amet dui. In et nisl quis enim condimentum vehicula. Aliquam tincidunt mi id justo elementum at laoreet velit tempus. Nulla elementum porta pulvinar. Duis at odio ipsum, ac eleifend sem. Sed elit odio, tincidunt ac convallis eu, auctor semper lorem. Nulla vel urna elit. Ut mi mi, molestie ut accumsan et, blandit ut diam.

Suspendisse quis neque eget orci gravida bibendum. Duis hendrerit, mauris sit amet laoreet semper, mauris odio bibendum neque, ac pharetra justo sapien nec quam. Curabitur volutpat vulputate vehicula. Curabitur eget dui purus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec posuere condimentum mauris, ac fermentum quam tincidunt id. Fusce lobortis blandit elit, iaculis mollis magna euismod sed. Ut tincidunt odio ac ligula viverra et elementum diam feugiat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Praesent interdum venenatis iaculis. Sed elementum neque sit amet mi volutpat pharetra.

In eget orci vel risus pulvinar vehicula. Nunc velit magna, pellentesque at vehicula et, vulputate in quam. Praesent venenatis molestie ornare. Sed quis turpis et urna ultrices auctor a bibendum nulla. Phasellus sem nisl, rhoncus quis placerat ac, rhoncus vitae massa. Donec semper, massa vel commodo elementum, mi quam congue elit, non laoreet tortor est aliquet mi. Nunc ac dolor eros. Vivamus cursus pharetra consectetur. Fusce lectus risus, lobortis at venenatis vitae, ultrices tempus sem. In blandit mollis odio ac porttitor. Vivamus non nulla quis ipsum consectetur rhoncus. Quisque in quam lacus.

Curabitur imperdiet ipsum rutrum velit scelerisque quis molestie arcu facilisis. Fusce faucibus purus nec nulla convallis eu aliquam metus auctor. In commodo urna non enim aliquet faucibus. Mauris ligula sem, gravida vel dapibus eu, vehicula nec magna. Curabitur sit amet nulla vitae libero scelerisque gravida. Maecenas tincidunt facilisis condimentum. Morbi non nisl neque. Donec auctor neque ac justo faucibus ac placerat eros rutrum. Aliquam pulvinar leo non eros ullamcorper ut laoreet ipsum interdum. Quisque aliquam, quam eget sodales varius, orci purus hendrerit mauris, blandit vestibulum sapien velit sed ante. Etiam porta ultrices augue, semper cursus lectus auctor quis. Integer sodales, nunc elementum aliquam auctor, tellus elit convallis justo, sed euismod nibh nisl sed neque. Sed venenatis condimentum ultricies. Nulla facilisi.