Wednesday, May 13, 2009

Ruby 1.8 xmlsimple.rb errors solved

Getting these errors when working with rails:

/usr/lib/ruby/1.8/xmlsimple.rb:275: warning: already initialized constant KNOWN_OPTIONS
/usr/lib/ruby/1.8/xmlsimple.rb:280: warning: already initialized constant DEF_KEY_ATTRIBUTES
/usr/lib/ruby/1.8/xmlsimple.rb:281: warning: already initialized constant DEF_ROOT_NAME
/usr/lib/ruby/1.8/xmlsimple.rb:282: warning: already initialized constant DEF_CONTENT_KEY
/usr/lib/ruby/1.8/xmlsimple.rb:283: warning: already initialized constant DEF_XML_DECLARATION
/usr/lib/ruby/1.8/xmlsimple.rb:284: warning: already initialized constant DEF_ANONYMOUS_TAG
/usr/lib/ruby/1.8/xmlsimple.rb:285: warning: already initialized constant DEF_FORCE_ARRAY
/usr/lib/ruby/1.8/xmlsimple.rb:286: warning: already initialized constant DEF_INDENTATION
/usr/lib/ruby/1.8/xmlsimple.rb:287: warning: already initialized constant DEF_KEY_TO_SYMBOL

Solution:

$ cd /usr/lib/ruby/1.8/
$ sudo mv lib/xmlsimple.rb lib/xmlsimple.rb.old
$ sudo mv xmlsimple.rb lib/

Monday, April 20, 2009

SSH and GSSAPIAuthentication

Reading the mail lists and forums you see quite a few people seem to be getting "slow" SSH connections when this option is turned on.

One way to "speed" up the connection is to turn it off, like so:

GSSAPIAuthentication no

in your .ssh/config file or on the command line like so:

ssh -o GSSAPIAuthentication=no


But what it is and what does it do?

GSSAPI stands for Generic Security Services API.

Just like its name suggests is a API that provides a standard interface for communicating with different protocols.

In SSH's case its designed to talk to Kerberos. But in case of Windows it can be made to talk to NTLM.

So what actually happens when SSH communication is initiated?

If you debug the connection you'll see something like this:

debug3: preferred gssapi-keyex,gssapi-with-mic,gssapi,publickey,keyboard-interactive,password

The server offers 'gssapi-keyex' as a possible authentication and the client tries to authenticate against it.

With the options listed above we just turn GSSAPI based authentication off on the client side. But a better solution, in case that you are not using this authentication at all, is to turn it off on the server side in /etc/ssh/sshd_config, likes so:

GSSAPIAuthentication no

Since SSH is almost universal way to connect to remote hosts/devices nowadays,
to insure a consistent authentication using GSSAPI, its very own RFC has been defined: RFC4462.

Friday, February 20, 2009

Suse10: eth0 renamed to eth1

uname -a: Linux sles10 2.6.16.21-0.8-default

I got this message: eth0 renamed to eth1

You can see the offending material in
/etc/udev/rules.d/30-net_persistent_name.rules:

SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="08:00:27:b8:c1:da", IMPORT="/lib/udev/rename_netiface %k eth0"
SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="08:00:27:06:67:20", IMPORT="/lib/udev/rename_netiface %k eth1"

Even though, there was only one card attached, I tried to remove the first line eth0 and rename the second interface eth1 to eth0, but no luck.

The dirty solution was to remove both lines and reboot, which resolved the issue.

Friday, February 6, 2009

Perl one liners

Join multiple lines:
perl -le 'print join " ", map { chomp; $_ } <>'

Convert unix timestamps:
perl -e 'print scalar localtime (TIMESTAMP)'

Thursday, February 5, 2009

Command-line Fu

This is such a great idea, I'm surprised nobody thought of it earlier:

Command-line-fu

A sort of like Digg for quick one liners.

Wednesday, February 4, 2009

Time zone calculator

To work out local GMT time use something like:


use POSIX qw(strftime);
strftime "%a %b %e %H:%M:%S %Y", gmtime;

Then either deduct or add in seconds, to work out time in a different time zone. Something like this:

# or for GMT formatted appropriately for your locale:
my $london = strftime "%a %b %e %H:%M:%S %Y", gmtime;
print "London $london\n";

# 8h * 60 min = 240 * 60 sec = 28800
my $seattle = strftime "%a %b %e %H:%M:%S %Y", gmtime(time - 28800);
print "Seattle $seattle 8 hours behind\n";

Nothing crazy, but useful.

Friday, January 9, 2009

Hardware database

The guys at UbuntuHCL have the right idea. They've created a hardware database where you can check compatibility of the hardware.

Going just by the name, as it says Ubuntu in the URL, you would be misled, since it keeps the track on compatibility with the other Unix/Linux OSes.

The great thing is, the reviews are created by the users. The downside is, its not that populated with reviews. So if you are reading this, be good, and fill in your hardware in there, help others :)

Wednesday, December 24, 2008

BlackBerry charging


When you connect your device to charge via USB cable to a Linux desktop it reports back something along the lines of:

"USB charging current is not sufficient. Verify that your handheld is connected to a powered USB charging source and that the proper USB driver is installed."

But if you use the same cable and connect it to the BlackBerry cradle first and then put your device into it, it will charge just fine.

No need to look around for a program that exists somewhere on the net that allows you to up your USB current output :)

Wednesday, December 17, 2008

Quicker cp/mv

Quick way to copy or move a file with less typing:


$ cp test{,.bak}
$ ls
test test.bak


will expand the first non existent parameter (note just the comma in the curly brackets) as the file name test making a copy named test.bak.

Very useful as it allowes you to type less since you have to supply only one argument plus the new file's extension.

Tuesday, December 16, 2008

Monitor dd(1) progress

When using dd(1) on command line you might want to see the speed it is being used at and its progress. This can be done by sending SIGUSR1 signal to the process, like so:

1. start dd: dd if=/dev/urandom of=/dev/zero

2. in another terminal run ps and find the dd's PID and send it SIGUSR1 signal like so:

kill -SIGUSR1 PID

which will output the results but in the first terminal where you started the dd process:

712107+0 records in
712106+0 records out
364598272 bytes (365 MB) copied, 64.4686 s, 5.7 MB/s

You can take this a bit further if the dd process is copying a large file and run it in a while loop at n intervals:


> while :
> do
> kill -SIGUSR1 13925
> sleep 5
> done

Monday, November 10, 2008

Sun's 7000 line of Open Storage appliances

What they offer ?

Smart NAS devices have embedded FISHWorks, which stands for: Fully Integrated Software and Hardware. Complete with SSD drives as storage.

1. The entry-level 7110 is called Iwashi, Japanese for a baby sardine.

2. Mid-range 7210 Fugu product, Fugu being a Japanese pufferfish which is lethally poisonous if prepared incorrectly. Let's not read anything into that.

2. Finally Toro, Japanese for fatty blue fin tuna belly, is the high-end product, the 7410. (the souce for Japanese names was taken from The Register)

Tech spec of 7410 and the types of RAID: Striping, Mirroring, RAID-Z, DP (RAID 5, 6). With DP being NetApp's not standard double parity storage.

Cool stuff: you can get the VMware demo from here to try it out. Or a web based one.

All this is great, but what is this Open in Open Storage ?

The answer lies in this quote from InfoWorld: "Some time after rolling out the NAS appliances, Sun will offer the software components as an "appliance kit" for OEMs (original equipment manufacturers) to build their own products. As an example, Sun pointed to Dell,..."

Theres your answer :)

Estimate the size of tar archive

If you ever need to find out how big your potential tar archive will be without creating it, try this little trick:

tar -cvf - XYZ | bzip2 | wc -c

Where XYZ is a file/directory you want to archive.

Thursday, November 6, 2008

Find out Netbackup's media & master server

Run the following command query Netbackup's Enterprise Media Manager about all the hosts it has visible to it.

/usr/openv/netbackup/bin/admincmd/nbemmcmd -listhost

It would list the media and master server, like so:

server hercules
master hercules

Thursday, October 23, 2008

Strip HTML

In some situations you have a installation instruction file that is in HTML. You want to read it in the console but you don't have links|elinks|lynx installed. What do you do ?

You pass the file through:


sed -e :a -e 's/<[^>]*>//g;/</N;//ba'


I used something like this before but lost it. Hence this blog, I want to keep little useful things like this to re-use.

A very useful way of using this is to bind it to a alias in your .profile as something like striphtml:


alias striphtml="sed -e :a -e 's/<[^>]*>//g;/</N;//ba'"


so that you have it handy. Which you can then use like:

striphtml readme.html | less


The original found here.

Tuesday, October 21, 2008

Debug Expect scripts

When running legacy expect scripts, you sometimes need to see what is being run and how. The easiest way to do that is to run the script with the -d switch. Like so:

script.exp -d

Also there is interact, about which you can read more here.

Sunday, October 19, 2008

Package management

List the files that make up a package:

pkgchk -l PKG | awk '/Pathname:/ {print $2}'

where PKG could be any package

Tuesday, September 30, 2008

ISO mount

Under Solaris

Make the block device with lofiadm:

lofiadm -a /path/to/image.iso /dev/lofi/1

Mount the image as a read-only hsfs filesystem:

mount -F hsfs -o ro /dev/lofi/1 /mountpoint

Under Linux

mount -o loop image.iso /mountpoint

Quick flarcreate usage

Quick reminder how to use flarcreate(1M):

flarcreate -n sol8 -S -R / /mnt/solaris8.flar

-n name of the archive
-S don't estimate the size of the archive prior to creating it
-R explicitly specifies / filesystem
solaris8.flar name of the archive

Wednesday, September 24, 2008

Move directory structure quickly

Sometimes you just want to move a directory structure quickly, to do that use pax(1), like so:

cd /dir/to/move

pax -rw /new/location

Thats it :)

Monday, September 8, 2008

How to run explorer on Solaris

Download and install explorer from Sun.

Then run:

/opt/SUNWexplo/bin/explorer

use -g switch when running it for the first time. This is just to configure contact and contract details.