Archive

Archive for the ‘Linux’ Category

GPG Errors

August 11th, 2009 No comments

Sometimes when you are installing RPM’s or Deb’s you will find yourself faced with GPG errors. Instead of ignoring them why not fix them!

Simply download the key by using the GPG tool:

gpg --keyserver pgpkeys.mit.edu --recv-key E6F33B6628973CC0

Then import that key into either apt:

gpg -a --export 010908312D230C5F | sudo apt-key add -

Or rpm:

gpg --export -a 010908312D230C5F >key.txt
rpm --import key.txt

Simple!

Tags: ,

HTML E-mails And Mutt

June 27th, 2009 2 comments

I find myself regularly using terminals and thus have grown to love any tool that allows me to remain in terminal. Mutt is only of those, a fantastic terminal mail client. The only issue is that most people these days send HTML e-mails rather than plain text. This means that when I open them in mutt it is very unreadable. However there is a very simple solution.

First off lets make a simple script to convert the HTML into text. Several terminal based browsers exist and these can do the conversion for us (make sure to place it in your PATH somewhere).

#!/bin/sh

if [ ! -z `which links | grep -v 'no links'` ]
then
  links -html-numbered-links 1 -html-images 1 -dump "file://$@"
elif [ ! -z `which lynx | grep -v 'no lynx'` ]
then
  lynx -force_html -dump "$@"
elif [ ! -z `which w3m | grep -v 'no w3m'` ]
then
  w3m -T text/html -F -dump "$@"
else
  cat $@
fi

Add this to your ~/.muttrc:

auto_view text/html
alternative_order text/enriched text/plain text text/html

And then this to your ~/.mailcap:

text/html;html2txt %s; copiousoutput

Start up Mutt and get nothing but text e-mails.

Tags: ,

CentOS NetInstall

June 7th, 2009 No comments

I recently reinstalled my CentOS (to upgrade to 5.3) and this time I decided to use a netinstall method. The netinstall can be very useful if you have a local repository of RPM files and even then it can be nice to download a very small ISO (only 8.3Mb).

So here is how you can do it for yourself. If you require to setup any partitioning scheme before hand, I highly recommend Partition Logic as a good run-from-CD partitioning tool. You will also need to download the small CentOS NetInstall ISO.

  • Boot from the ISO
  • Type linux askmethod at the boot prompt
  • Select the required network setup. Normally DHCP is good enough, disable IPv6 unless you plan on using it.
  • Select HTTP as the installation method.
  • If you have a local web server with your RPM’s on it then put in the information there. Otherwise use: mirror.centos.org and centos/5.3/os/i386.
  • Finally start the installation process.

The whole thing should take no more than a couple of hours to complete. This method allows you to quickly start an installation of CentOS without the need to download all 6 of the CD’s or the DVD image.

Tags: ,

Error Codes

June 1st, 2009 No comments

I recently came across this caused me to smile if not giggle.

ENOTOBACCO		Read on an empty pipe
EBEFOREI		Invalid syntax
ECHERNOBYL		Core dumped
ECRAY			Program exited before being run
EDINGDONG		The daemon is dead
EFLAT			System needs tuning
EGEEK			Program written by inept Frat member
EIEIO			Here-a-bug, there-a-bug, ....
EIUD			Missing period
ELECTROLUX		Your code could stand to be cleaned up
EMILYPOST		Wrong fork
END.ARMS.CONTROL	Silo overflow
ENOHORSE		Mount failed
ENONSEQUETOR		C program not derived from main(){printf("Hello, world");}
EWATERGATE		Extended tape gap
EWOK			Aliens sighted
EWOK			Your code appears to have been stir-fried
EWOULDBNICE     	The feature you want has not been implemented yet

Not to be out done, a new signal:

SIGNUKE     	Nuclear event occurred (cannot be caught or ignored)
Tags: ,

Skinning A Cat

May 17th, 2009 No comments

I was recently discussing with someone about sed usage. They were having difficultly creating an appropriate regex to handle their problem:

(Orlando) sed regex kicks my ass.  I like to remove the second : in the
line. So that in 123:456:6789 it will only returns 123:456.  I can find the
first :, but I have not been able to use s/:{2}// to find the second
one, and remove the rest.

I enjoy regex (I know I’m weird, leave me alone), so I was able to provide an answer to this problem:

(@znx) Orlando: the trick is to use [^:] and \1 ..
(@znx) like:   s/\(:[^:]*\):.*/\1/

Now obviously at first glance this regex could be a bit intimating to someone who is still picking up the skills but as with most things if we break it down it becomes easier.

Working out to in, \( \):.*, that says match something with : at the end and all the character after it. The . is a special meaning “any character” and * to match multiple characters. The first match will be stored by sed and assigned into the \1 for the replacement (that is what the brackets do). Inside the brackets we have :[^:]*. The sequence [^ ] is a negated list, that means that we are asking it to match everything that is NOT inside the list, in this case :.

Putting it altogether we are saying: Match a leading : and a trailing : with any characters after it. Placing the contents between the two : in memory. Then finally we replace the contents.

% echo 123:456:6789 | sed 's/\(:[^:]*\):.*/\1/'
123:456

Sucess, however as with most things, there is more than one way to skin a cat and regex is rarely the prettiest method. So what other ways can we solve this problem?

With AWK:

% echo 123:456:6789 | awk -F: '{print $1":"$2}'
123:456

With cut:

% echo 123:456:6789 | cut -d: -f1,2
123:456

As always, experimentation with the mass of GNU tools you can find on your system will bring a greater deal of power to your tool chest. Mind you, then I wouldn’t get complements for helping would I?

(Orlando) Wow, When I grow up, I like to remember this thing like you do. :-) 

Haha, till next time!

Tags: ,