Wednesday, April 23, 2008

Pick up the car today

Roo bar, fully sick flood lights, lifted suspension.

Monday, April 14, 2008

Geek Post

Tidying up XML with HTML tidy.
to tidy an XML file in the unix world use the following:

$tidy -xml -i -m --wrap "80" file.xml

in the windows world:

C:/program files/path to tidy/tidy.exe -xml -i -m --wrap "80" file.xml

Monday, April 07, 2008

Geek post

I'm having a problem at work. Students using a ADSL2+ with TPG (an ISP) are experiencing slow connections when downloading recordings (pod casts) of their lectures. Some students have submitted problem tickets to the database we maintain to help diagnose exactly this type of problem.

I need to provide TPG with details of the students who have this problem to help them sort out what is going wrong within their network. When the students submit their problem we record their IP address. Anyway, here is a useful little unix bash shell script I wrote which will read through a list of ip addresses and then do a whois lookup on each one and will print out all the ones from a particular provider.

# script that iterates through a list of ip's in a file provided through stdin
# does a whois look up on each of them and then prints out all the ones with
# a particular ISP - in this case TPG

FILE="" # variable to hold the file name
if [ "$1" == "" ]; then # if there is no file as an arg
FILE="/dev/stdin" # then get it from stdin
if [ ! -f $FILE ]; then
echo "$FILE : does not exists"
exit 1
elif [ ! -r $FILE ]; then
echo "$FILE: can not be read"
exit 2

cat $FILE | while read LINE # pass the file line by line
ISP=`whois $LINE | grep netname | awk '{print $2}'`
if [ "$ISP" == "TPG-AU" ]; then
echo "$LINE"
sleep 2

I always find examples like this found on other peoples blogs useful when searching the web for snipits of tested code.