Wednesday, July 16, 2008

Needs more cow...say!

I stumbled across a wonderful program today: cowsay! It is just as cool as you would imagine:
cowsay "Text"
gives you an ASCII-art cow saying your Text.

I think I will use it as the welcome banner on all my servers:

Thursday, July 10, 2008

Handy Network Utilities: nast, fping

I discovered a wonderful utility last night: nast. I wanted to scan my local network, just to see what devices were on it, what their addresses were, etc. I could ping my entire subnet, but what if I had a machine that rejected ICMP packets? (Not that I do very often, but it can happen in larger environments). I thought using a protocol like ARP would be much more robust, since it is pretty much guaranteed to be available. Then I discovered nast.

nast can do a lot of neat things. The first I found was mapping a subnet of course, which you can do by running
sudo nast -i eth1 -m
adjusting the interface to fit. It will return something like:
Nast V. 0.2.0

Mapping the Lan for subnet ... please wait

MAC address Ip address (hostname)
00:19:D2:92:20:CE (MyGateway)
00:1B:C0:B7:86:CB (MyBox) (*)
00:14:38:E5:76:10 (SomeOtherBox)
nast can also try to find out if there are any nodes on your subnet acting in promiscuous mode, which I think is pretty hot. Check out the main nast page for the full feature set.

In my searching, I also came across fping. Its main improvements over regular old ping are:
  • More than one host can be passed (as well as a file containing hosts)
  • Its output is very simple and easy to parse, making it ideal for scripting
  • It tries each host and moves on if there is no response, making the whole process faster
Instead of
ping -c 1 myhost1 ; ping -c 1 myhost2
you can just run
fping myhost1 myhost2
which just returns
myhost1 is alive
myhost2 is alive
Both nast and fping are available in the Ubuntu repos.

Wednesday, July 9, 2008

Crashing Application Greeter

I was playing around with themes and the like in Hardy Heron recently, and I ended up selecting a new login screen. Apparently, something was wrong with the one I installed, however, since the next time I went to login, I was presented with a black screen and the message "The greeter application appears to be crashing. Attempting to use a different one." Hitting Ok on this merely cycled through X starting up and led to the same message.

To fix this, I went into another tty with Alt + F2, logged in, and ran "sudo vim /etc/gdm/gdm.conf". I commented out the line "Greeter=/usr/lib/gdm/gdmgreeter" and added "Greeter=/usr/lib/gdm/gdmlogin". After restarting, a simple Gnome login screen appeared fine, which allowed me to get in and change the login screen to a know safe default.

Tuesday, July 8, 2008

Additional Tips for GNOME-Do

After having played with GNOME-Do for a few days, experiencing some pain and finding more fun things, I have some suggestions that may make your adoption of it smoother.
  • Get to 0.5. 0.4 will likely be in your repo, so beware! It is a paltry substitute. If you have installed that, remove it and delete the plugins dir. Then add the repos to your "/etc/apt/sources.list" as described here, then run "sudo apt-get install gnome-do". Also, make sure you kill GNOME-Do if it is running, BEFORE you remove the old version and try to install.
  • 0.5 has a lot of great features, mainly the built-in Preferences window, which lets you just check plugins you want. There is also a new Open With action, which comes in very handy. Get to 0.5.
  • Very neat plugins: Skype (lets you chat or call with Skype contacts, like the Pidgin plugin), Upload to Flickr, Locate Files, Rhythmbox.
  • Install "xclip" (is in repos). This will let you select any text, invoke GNOME-Do, and act on that text.
Once I got to 0.5 and got those plugins running, GNOME-Do started becoming even handier!

Thursday, July 3, 2008

Killer App: GNOME-Do!

I started to doubt my beloved Ubuntu after a co-worker showed me the various virtues of Quicksilver on the Mac. But, I have... Beagle? Yuck. Lunchbox was cute, but never seemed to work right. But today, I take that doubt back, great Linux gods. Behold: GNOME Do!

If you know what Quicksilver is, then you are basically there. If you don't, just imagine a pretty app launched by a simple key combo that lets you do anything from open files, to play songs, to email people with just a few easy keystrokes.

David Siegel's beautiful site has lots of documentation, plugins, and more. Just be on Gutsy or Heron, add a repo to your sources, install. In case you don't know what "super-space" is, as I didn't, super is the meta key, so the one with a Windows Logo on it on most keyboards.

Some additional plugins I installed and found handy:
  • - Search your bookmarks and public ones
  • Rhythmbox - Play songs in your library, control volume, and more
  • Pidgin - IM people in your Pidgin lists

Wednesday, July 2, 2008

Handy script: LAMP stack version printer

Often when troubleshooting or setting up servers, I need to know the installed versions of applications commonly grouped into the "LAMP" stack. I dislike having to remember the slight differences between them when trying to coerce each to divulge their version. So I created a script that does that, and even prints it all in easy-to-read colors!

The code:
# Written by Samuel Huckins
# July 2007
# Prints out version info for
# things in the LAMP stack.
echo -e "\e[1;34mThis machine's LAMP stack:\e[0m"
echo ""
# Linux:
LINUX=`cat /etc/issue`
echo -e -n " * \e[31mL\e[1;33minux: \e[0m"
echo "$LINUX"
# Apache:
echo -e -n " * \e[31mA\e[1;33mpache: \e[0m"
if [ -e /usr/sbin/httpd ]
echo "`/usr/sbin/httpd -v| head -n 1 | awk '{print $3}'`"
elif [ -e /usr/sbin/apache2 ]
echo "`/usr/sbin/apache2 -v| head -n 1 | awk '{print $3}'`"
echo -e "\e[37mNot present\e[0m"
# MySQL:
echo -e -n " * \e[31mM\e[1;33mySQL: \e[0m"
if [ -e /usr/bin/mysql ]
echo "`/usr/bin/mysql --version | awk '/Ver/ {print $2, $3, $4, $5}' | sed 's/,//'`"
echo -e "\e[37mNot present\e[0m"
# PHP:
echo -e -n " * \e[31mP\e[1;33mHP: \e[0m"
if [ -e /usr/bin/php ]
echo "`php -v`"
echo -e "\e[37mNot present\e[0m"
# Perl:
echo -e -n " * \e[31mP\e[1;33merl: \e[0m"
if [ -e /usr/bin/perl ]
echo "`perl -v | awk '/This is perl/ {print $4}' | sed 's/v//'`"
echo -e "\e[37mNot present\e[0m"
# Python:
echo -e -n " * \e[31mP\e[1;33mython: \e[0m"
if [ -e /usr/bin/python ]
echo "`/usr/bin/env python -V 2>&1 | awk '/Python/ {print $2}'`"
echo -e "\e[37mNot present\e[0m"
# done
echo ""
The result:

Call it "", and add something like "alias lamp="~/my/code/". Couldn't be easier.

Minor caveat: While the script does check each program for existence, I only check the most common place. It could be better expanded to cover less used locations for applications, conventions on more OSes, etc.