HP Laserjet P1006 CUPS Fix

August 30th, 2009 by MadHatter

Frustrating issue today with a fairly common printer I purchased for school use. An HP Laserjet P1006. CUPS seemed like the logical solution for network printing. Set the printer up in the guided setup (System > Administration > Printing) in Ubuntu 8.04. It detected it immediately and then found a driver for it. All seemed well but when I hit the “Print test page” option nothing happened. The print job stated that it was completed around a minute later. No errors were found in CUPS logs. After some searching I found a tutorial to manually install the correct driver (http://foo2xqx.rkkda.com/). The problem with this is that you have to remove the printer entry you created previously before continuing with this step-by-step tutorial. I tried just deleting the printer I had added, but it didn’t work. I started fresh and removed CUPS, then re-installed:

sudo apt-get remove cupsys cupsys-client

sudo apt-get install cupsys cupsys-client

I also removed the printer configuration:

sudo rm /etc/cups/printers.conf

sudo rm /etc/cups/printer.conf.O

This may have been overkill and I had no previous printers configured, so you may not need to (or want to) remove those files.

After those removal steps I continued with the tutorial once again foo2xqx.rkkda.com and all worked correctly. I chose the option NOT suggested by Ubuntu when drivers were being chosen. Test print was successful. Quite frustrating that such a common printer is having issues with CUPS. Hopefully this can save someone else the trouble I went through figuring this out.

Posted in Education, Technology | No Comments »

Twitter Weather Forecasts Using Linux

March 11th, 2009 by MadHatter

twitter sh2

Twitter’s feature to allow updates from terminal allows for a lot of creative ways to use twitter. I used some already written scripts and commands and put it all together to receive weather forecasts for my area at 9am every day on my phone.  Example of SMS message sent to my phone “Forecast for: DES MOINES, IA    Today    Mainly clear and frigid – Low 10“  Here is how I did it:

First I used a written shell script and made output modifications so length would be under Twitter’s length limitations. The modified script is listed below:

Note: I take no credit for the original script. It was available online, and I modified it based on my needs. Dave Taylor is the original author, and offers a book full of shell scripts I recommend checking out! Page Here

#!/bin/sh
# weather – report weather forecast, including lat/long, for zip
# Dave Taylor – found at
http://www.intuitive.com/wicked/showscript.cgi?063-weather.sh
# Edited for twitter use by MadHatter (maddhat.com)

llurl=”http://www.census.gov/cgi-bin/gazetteer?city=&state=&zip=”
wxurl=”
http://wwwa.accuweather.com
wxurl=”$wxurl/adcbin/public/local_index_print.asp?zipcode=”

if [ "$1" = "-a" ] ; then
size=999; shift
else
size=5
fi

if [ $# -eq 0 ] ; then
echo “Usage: $0 [-a] zipcode” >&2
exit 1
fi

if [ $size -eq 5 ] ; then
echo “”

# get some information on the zipcode from the Census Bureau

lynx -source “${llurl}$1″ | \
sed -n ‘/^<li><strong>/,/^Location:/p’ | \
sed ’s/<[^>]*>//g;s/^ //g’
fi

# the weather forecast itself at accuweather.com

lynx -source “${wxurl}$1″ | \
sed -n ‘/Start – Forecast Cell/,/End – Forecast Cell/p’ | \
sed ’s/<[^>]*>//g;s/^ [ ]*//g’ | \
sed ’s/10-Day AccuWeather.com//’ | \
sed ’s/Today/Today:/’ | \
uniq | \
head -$size

exit 0

Save this as weather.sh in your home folder. Then open a text editor and create “tw.sh” saved to your home directory with the following contents:

Note: You need to replace the USER:PASSWORD with the username and password for the secondary twitter account.

#!/bin/sh
#tw.sh
curl -u USER:PASSWORD -d status=”$*”
http://twitter.com/statuses/update.xml

For this script to run correctly curl must be installed. For ubuntu the command is “sudo apt-get install curl

Now we have the necessary scripts created. To receive updates you will need to create a second twitter account of which to send updates. Make sure you follow this new account with your primary twitter account and turn on device updates if you are looking for update to your mobile device.

All that is left to get things up and running is to add the crontab entry. I added to my sudo crontab by the following “sudo crontab -e” and adding the following entry:

Note: This will run at 9am every day. You can edit yours however you’d like. For testing it may be a good idea to start with “* * * * *” to run every minute to ensure updates are working as planned. Replace “user” with your user name, as well as ZIPCODE with the zip code of the area you would like weather forecasts for.

0 9 * * * /home/user/tw.sh $(/home/user/weather.sh ZIPCODE)

Save the crontab entry. Check that it was added by typing “sudo crontab -l”. That’s all there is to it.
Some useful links for help and customization:
Twitter API, Cron.

Posted in Education, Technology | No Comments »

Testing Network Performance Using Iperf

March 10th, 2009 by MadHatter

Just a quick post on a great tool for testing network performance. Iperf is a very slim tool that will measure TCP/UDP bandwidth performance. It is an available ubuntu package “iperf ” and also has Windows/OSX binaries available. I found a working mirror here. What makes Iperf a good test versus a simple SMB/CIFS transfer for bandwidth performance is that it works in memory versus being limited by hard drive and CPU limitations.

Now a quick guide to get things up and running. The guide will be for two Ubuntu machines, testing network performance between the two.

1.Install – Type the following in terminal “sudo apt-get install iperf ” for both machines

2.Server Setup – Decide upon a server machine and a client. On the server type the following in terminal “iperf -s ”. This will place iperf in server mode, and it will listen for incoming connections.

iperf server

3.Client Setup - On the client machine you have a lot of options to play around with regarding how you want to connect to the server. You can explore what each of these are by typing “iperf –-help ”. The following is a simple test between the server (192.168.2.104), and the client (192.168.2.103).

4.Testing - Type “iperf 192.168.2.104 -i 2” (replacing the IP here with the test server IP and then enter key to start testing. This will connect to the server running on 192.168.2.104 and have an interval of 2 seconds. There will then be 6 tests completed. This should give you all of the information you need regarding your connection speed between the two machines.

iperf client

This should be enough to get you started using iperf. Check out the man page here if you have any usage questions.

Posted in Education, Technology | No Comments »

« Previous Entries