Archives for November, 2010

29
Nov

Time Tracking in the Command Line (Python and Shell Scripts)

If you’re doing consulting work and/or wanting to keep track of time spent on your todo list items from a command line interface (CLI), look no further than the following two scripts. They are simple to use and have a fair amount of power and flexibility in them. The first is a shell script which tracks your todo items. The second is a Python script which wraps itself around the todo list and give you the ability to punch in and out of the task your working on. Be sure to visit the homepages of each tool to get more information.

http://ginatrapani.github.com/todo.txt-cli/
http://code.google.com/p/punch-time-tracking/

17
Nov

Set stderr or stdout Redirection for Entire Script

Here’s a quick to to enable standard error (stderr) redirection for an entire script. Just put this command on the top of your script:

exec 2>> stderr.log

Here’s a quick example script to demonstrate:

#!/bin/sh

exec 2>> stderr.log

echo "Hello There! This stdout statement has been redirected to stderr." 1>&2

The output of cat stderr.log:

Hello There! This stdout statement has been redirected to stderr.

The same thing applies for standard out (stdout), except you use “1″ instead of “2″:

exec 1>> stderr.log

Here’s a quick example script to demonstrate:

#!/bin/sh

exec 2>> stderr.log

echo "Hello There! This is a stdout statement."

The output of cat stderr.log:

Hello There! This is a stdout statement.
15
Nov

A Great Presentation Explaining Motivation of Things Like Linux/OpenSource

When chatting with non-Linux folks about Linux, the question that normally comes up is “why are they [the developers] doing all of this for free?”. Up until a few days ago, I didn’t really understand it myself, so I had difficulties in explaining it. I stumbled upon the following video which might give an explanation to that question:

YouTube Preview Image

Now, whenever somebody asks, I’ll be able to simply point ‘em to the video (or paraphrase it)! I found it to be easy to understand and fun to watch. I hope you enjoyed it as well. RSA Animate did a good job on this one.

12
Nov

A Nice Color Scheme Tester Script for Terminal Shell

This is a shell script that outputs your current unix color scheme. This is handy for when you’re trying to come up with your own theme. It comes from http://www.frexx.de/xterm-256-notes/. I’m taking no original credit for this script. I simply want to share it with the readers since I found it very clean and useful. You simply copy the code to a script, use ‘chmod +x colortheme.sh’ as usual, and then run it with ./colorscheme.sh. I’m going to duplicate the script here for redundancy (I want to make sure it’s always there for myself too!):

#!/bin/bash
#
# Description:
#
#    Prints a color table of 8bg * 8fg * 2 states (regular/bold)
#
# Copyright:
#
#    (C) 2009 Wolfgang Frisch <xororand@unfoog.de>
#
# License:
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

echo
echo Table for 16-color terminal escape sequences.
echo Replace ESC with \033 in bash.
echo
echo "Background | Foreground colors"
echo "---------------------------------------------------------------------"
for((bg=40;bg<=47;bg++)); do
	for((bold=0;bold<=1;bold++)) do
		echo -en "\033[0m"" ESC[${bg}m   | "
		for((fg=30;fg<=37;fg++)); do
			if [ $bold == "0" ]; then
				echo -en "\033[${bg}m\033[${fg}m [${fg}m  "
			else
				echo -en "\033[${bg}m\033[1;${fg}m [1;${fg}m"
			fi
		done
		echo -e "\033[0m"
	done
	echo "--------------------------------------------------------------------- "
done

echo
echo
10
Nov

XML Pretty Printer

A nifty tool when dealing with misfit XML documents is XML Pretty Printer. This command line tool will do exactly as it says: print pretty XML. Example usage:

xml_pp foo.xml > foo_pp.xml

In order to install xml_pp, you’ll need to use your package manager. For example, in Fedora you use yum install perl-XML-Twig and in Debian/Ubuntu you use apt-get install xml-twig-tools.

As always, be sure to check out the man page for xml_pp.

8
Nov

Gobby: Cross Platform Real-Time Collaboration Software

Take a moment or set aside some time to check out a cross platform, real-time collaboration software program called Gobby. Here’s the standard blurb from the projects homepage:

Gobby is a free collaborative editor supporting multiple documents in one session and a multi-user chat. It runs on Microsoft Windows, Mac OS X, Linux and other Unix-like platforms.

Gobby has many excellent features and is a very promising application in terms of synchronous collaboration software. I have yet to get my hands dirty with it, but my initial thought is that this is the “missing-link” that I’ve been searching for so that I may assist or collaborate code with others. I’ve given ethercodes.com and Google docs a whirl, but they just seem clunky when it comes time to actually testing the program you’ve collaborated on (lots of copy/paste between web browser and terminal).

Looks like Linux.com has a nice article on setup and usage, so be sure to check it out for more information. I will probably try to create my own once I get the hang of it. :)
http://www.linux.com/archive/articles/55361

5
Nov

Speed Up Compilation with the “–jobs” Make Option

Here’s a quick, simple tip to speed up the time it takes to compile a kernel or other program with a well designed Makefile (i.e. BusyBox): use the --jobs or -j make option. This will allow the compiler to execute in parallel in what’s known as recipes. Here’s a quick example for compiling a kernel zImage bootable image:

make -j4 zImage

This will spawn off 4 parallel compiling processes. There is not a limit for the number of job slots that you can use, but I’ve been told that as a general rule of thumb not to exceed more than twice the number of CPU cores you have. I don’t have any references (or extensive experience) to back that up, so take it for what it’s worth.

For more information, see the following resource:
http://www.gnu.org/software/automake/manual/make/Parallel.html

3
Nov

Add Color to Your Scripts

There are ANSI escape sequences which allow you to set text attributes such as bold text and the color of the foreground and background of the text. You can incorporate these escape sequences into your scripts or shell. See the following resource for more information:

http://tldp.org/LDP/abs/html/colorizing.html

2
Nov

Fedora 14 Laughlin on MacBook Aluminum [Guide]

This is a guide to getting Fedora 14 Laughlin running on a MacBook Aluminium. Specifically, it was written for the MacBook 5,1 generation, but I believe this should work on more recent generations as well. As with Fedora 13, there were many things that worked out of the box. I have created this guide to help others get Fedora 14 installed on their MacBook Aluminum.
[Read more →]

2
Nov

How To: Install VirtualBox 3.2 on Fedora 14

This is a step by step tutorial on how to get VirtualBox 3.2 up and running on Fedora 14. Specifically, this guide was written using the VirtualBox 3.2.10 (32-bit) version. It can be adapted to upcoming versions and different CPUs (64-bit). The folks at VirtualBox have made it easy to install for Fedora users and I’m going to show you how in a few easy steps. Right, open a terminal window and let’s get to it…
[Read more →]