Sunday, September 12, 2010

tar compression



Tar contains a few options to compress the tar-ball. It depends on what compression packages you have installed. I have long known that LZMA is good for making small packages when I can spare the time. For everything else I use BZIP2. Fortunately curiosity has led me to do a small comparison.

More about the Graph.
Compress and uncompress times are in relation to one another, thus they are comparable, as well as /tmp/etc and /tmp/bin.

Size is the ratio of compressed-tar-ball to the disk space as reported by du. It is then adjusted to fit within the ratio, /tmp/etc and /tmp/bin are comparable.

Data for /tmp/etc was copied from /etc with
cp -r /etc /tmp/etc. Same thing for /tmp/bin.

Wednesday, August 12, 2009

How to telnet to Vocality devices from Linux

How to telnet to Vocality VOIP (www.vocality.com) devices from Linux.
Alternative heading: How to make kermit behave like hyperterminal.

Target device: http://www.vocality.com/v150/ from here on caller V150
Linux Distribution: openSUSE 10.3 http://www.opensuse.org/

When one telnet from Linux or MacOS X to a V150 the Up and Down keys on the keyboard do not work, this makes navigation in the V150 near impossible. Along with the arrow keys that is not working there is also a problem with the combination keys like Ctrl+e. For long I have had a crooked workaround, that did not involve using hyperterminal. (I am fortunate enough to not have access to a MS device)

Today I took some timeout to configure kermit to give me the correct user experience. I chose to explore kermit for this application since I wish (its done now) to automate certain tasks.

I'll focus on configuring kermit for telnet only. You should install kermit yourself there are enough docs to help with that.

Edit you local users kermit startup file .kermrc located in your users home directory.
# vi ~/.kermrc

Add the following lines to that file.

SET TELOPT AUTHENTICATION REFUSE
SET TELOPT KERMIT REFUSE REFUSE
SET TELOPT NEW-ENVIRONMENT REFUSE
SET TELOPT NAWS REFUSE
SET TELOPT FORWARD-X REFUSE
SET TELOPT COM-PORT-CONTROL REFUSE
SET TELOPT AUTH REFUSE
SET TELOPT TERMINAL-TYPE REFUSED
SET TELNET BINARY-TRANSFER-MODE OFF
SET TELNET AUTHENTICATION FORWARDING OFF
SET TELNET AUTHENTICATION TYPE NONE
SET TELNET NEWLINE-MODE OFF
SET TELNET TERMINAL VT100


Most of the above is probably already in your ~/.kermrc file.
Next you launch kermit in network mode to you V150 device. For my example one of my V150 is on IP address 192.168.1.10

#kermit -J 192.168.1.10

That should give you control over the device as if you were accessing it form hyperterminal.

Some kermit:
http://www.columbia.edu/kermit/

The kermit escape key is “Ctrl+\
For help in the telnet session “Ctrl+\” then “?” this will guide you through the options.
To disconnect use “Ctrl+\” and “u

Sunday, February 1, 2009

Get data from busted ntfs partition.

Found a very cool and handy utility to recover data from an ntfs drive that was reformatted to FAT32.

http://memberwebs.com/stef/software/scrounge/

No need for me to explain the workings the documentation is good.

A friend was migrating from a Windows XP Laptop to a nice new Shiny MacBook. In the process he reformatted one of his USB 500GB drives, was NTFS, to FAT32 for cross compatibility. Unfortunately the backups of the drive was not good. So there we were a few Gig's of very good high quality photos gone. 

A hand full of standard unix tools and scrounge-ntfs has helped me to recover the data. Scrounge takes a few simple parameters one being the drive to scan and another a destination directory to dump the recovered file. 

for reference here is my executed command.
scrounge-ntfs -m 6291456 -o /data/d5/rescue /dev/sdf 63 1953546210

All in all scrounge-ntfs was easy to compile, clear documentation, simple parameter options and it works well, It saved the day.

Friday, December 12, 2008

Using inode numbers to handle wacky filenames

Lately I keep on running into filenames with spaces and whacky characters at first I renamed them all but they keep on getting into the process queue. So here is how I handle them in shell scripts.

Filenames with spaces in are still evil, but we do not mind evil.

#! /bin/sh

# Code Example with limited explanation, It is self explanetory.

FILE_LIST=`ls -i1 | awk '{print $1}'`

for FILE_INODE in $FILE_LIST
do
echo -n "INODE:$FILE_INODE "

# To get the File Name
FILE_NAME=`find -inum ${FILE_INODE}`
echo "FILENAME:$FILE_NAME"

# Example of giving the filename as an argument to a program
cat "$FILE_NAME" > /dev/null

# Passing filename to program straight from find, This is handy for deleting some really obscure files. eg. files with no name.
find -inum ${FILE_INODE} -exec cat {} > /dev/null \;
done

Monday, October 8, 2007

Flipping a coin in Bash

I took the day off to look for a new laptop. So I devised this clever little script to manage my time today.

#! /bin/bash

# Flip a coin to see if I should have another beer.
# experimentaly biased. :-)

HEAD=0
TAIL=0

for x in 1 2 3 4 5 6 7 8 9
do

FLIP=$(($(($RANDOM%10))%2))

if [ $FLIP -eq 1 ]
then
echo "TAIL"
TAIL=$(($TAIL+1))
else
echo "HEAD"
HEAD=$(($HEAD+1))
fi
done

if [ $HEAD -gt $TAIL ]
then
echo "BEER TIME.!"
else
echo "Your not entitled to a beer. Run $0 again."
fi

I am still looking for a new laptop.

Thursday, September 20, 2007