serfGeek's Geek::Blog

All of John Harrison's geek notes which don't need to go in the Wiki but are too techy to put in the personal blog...

Tuesday, March 03, 2009

Dead ringer... 

How to disable bells all over the place...

To turn off that annoying flash (that lags your session) in vim:

In .vimrc


set vb t_vb= " Turn off visual bell


General beeps...

In .inputrc


set bell-style none


In ~/.bash_profile (or /etc/profile or .bashrc or somewhere)


setterm -blength 0


In X Window:


$ xset b off


To turn it on again use:


$ xset b on


For less

In ~/.bash_profile:


export LESS="-q"

posted by John  # 1:26:00 PM

Monday, February 23, 2009

htmlify a script -x 


sh -x try.sh 2>&1 | sed "s/^+ \(.*\)$/\n$ <b>\1<\/b>/g;"

posted by John  # 7:23:00 PM

heads or tails? don't be so negative... 

The number of lines options with head and tail do not have to be negative...

After 15 years of using head and tail (and wondering why they are encourage the use of the "extra" '-n' option now!) a question just occurred to me...

"What if I don't know how many lines I want to see with tail, I just know I want to skip the first X lines...?"

The logical opposite of:

tail -X FILENAME

would of course be:

tail +Y FILENAME

Which (thanks to Unix being so logical) naturally works!

You wouldn't really want to use it without a -n in front because +NUM would more likely be a valid file name than a switch, so you do get a warning:


$ tail +20 FILENAME
tail: Warning: "+number" syntax is deprecated, please use "-n +number"


and head just barfs:


$ head +20 FILENAME
head: cannot open `+20' for reading: No such file or directory


So use:


$ tail -n +$SKIP FILENAME


Given the file:


$ seq 1 5 > FILENAME
$ cat FILENAME
1
2
3
4
5


Let's unit test...


$ head +2 FILENAME
head: cannot open `+2' for reading: No such file or directory
==> FILENAME <==
1
2
3
4
5


means: "head the files '+2' and 'FILENAME'"


$ head -2 FILENAME
1
2

$ head -n 2 FILENAME
1
2

$ head -n +2 FILENAME
1
2


all mean: "show the first 2 lines of FILENAME"


$ head -n -2 FILENAME
1
2
3


means "show all BUT the last 2 lines of FILENAME"


$ tail +2 FILENAME
tail: Warning: "+number" syntax is deprecated, please use "-n +number"
2
3
4
5


means "I'm being too lazy to use -n, but show me FILENAME from line 2 down"


$ tail -2 FILENAME
4
5

$ tail -n 2 FILENAME
4
5

$ tail -n -2 FILENAME
4
5


mean "Show me the last 2 lines of FILENAME"


$ tail -n +2 FILENAME
2
3
4
5


means "Show me FILENAME from line 2 down"

posted by John  # 6:18:00 PM

Wednesday, February 18, 2009

vi - delete all matching lines... 

:%g/^sometext,/ d

search range (all lines) : %
beginning with "sometext,
execute the Ex cmd "d" ; delete the line

posted by John  # 7:56:00 PM

Thought for the day... 

People that call it V I instead of "vie"...

...probably don't need a "vi quick reference guide/cheatsheet" anyway.

:o)

posted by John  # 4:18:00 PM

Tuesday, February 17, 2009

Add correct host key in /home/john/.ssh/known_hosts to get rid of this message. 


john@hostname:~/.ssh$ ssh user@hostname
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for hostname has changed,
and the key for the according IP address 123.45.67.89
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
01:23:45:67:89:ab:cd:ef:fe:dc:ba:98:76:54:32:10.
Please contact your system administrator.
Add correct host key in /home/john/.ssh/known_hosts to get rid of this message.
Offending key in /home/john/.ssh/known_hosts:9
RSA host key for hostname has changed and you have requested strict checking.
Host key verification failed.


The known_hosts file is now encrypted, which makes it harder to find the bad line...
but you will note the line that says:

Offending key in /home/john/.ssh/known_hosts:9

(where :9 means line 9)

If you comment out or remove the line that the error indicates, this should fix the problem.

Alternatively, you can remove an entry for a given host using:


$ ssh-keygen -R hostname


Or find it with:


$ ssh-keygent -F hostname

posted by John  # 6:25:00 PM

Thursday, February 12, 2009

find grep hack to show name and content... 

For a long time I've done things like:


for FILE in $(find * -type f -exec grep -l "$STRING" {} \;)
do
echo -n "$FILE"
grep -n "$STRING" $FILE
done


to get both the filename and the string it's matching on because there's no "name plus match" flag for grep... you either have -l or -n but not together...

I had a brainwave just now...

If you give grep more than one file to grep in - it tells you which file it found the match in... so how about:


$ find * -type f -exec grep -n $STRING {} /dev/null \;
path/to/the/FILE:12:I found $STRING on line 12!


If you can't be bothered typing, it can be any valid filename instead of /dev/null - i.e.:


grep -n $STRING {} /
grep -n $STRING {} .
grep -n $STRING {} *


I just figured /dev/null should hopefully have the least overhead to stat.

Be careful you don't give it an invalid filename or you'll get an error for each file the find finds!


$ find * -type f -exec grep STRING {} no_such_file \;
grep: no_such_file: No such file or directory
grep: no_such_file: No such file or directory
grep: no_such_file: No such file or directory
grep: no_such_file: No such file or directory
grep: no_such_file: No such file or directory

posted by John  # 11:40:00 AM

Tuesday, October 14, 2008

Holding Debian versions 

Hold is a status flag which tells apt (or aptitude) not to automatically upgrade a package.
To hold a package, 'echo pkgname +hold|dpkg --set-selections'
or 'aptitude hold package'
or use = in aptitude's curses interface.
You can ignore a hold by using apt-get install foopkg; or by using ++ in aptitude's curses interface.
[Note that this is *NOT* the same as packages which have been "held back" for dependency reasons.]

Snapshots is an archive that contains all Debian packages uploaded since 2002,
including those removed from the official archives because they were very buggy, unusable, broken, vulnerable or in some way undistributable.
Much of 2004 was lost because of harddisk problems.
See http://snapshot.debian.net/ for more information.

e.g.
dpkg -i /var/cache/apt/archives/sun-java5-bin_1.5.0-14-3_i386.deb /var/cache/apt/archives/sun-java5-jre_1.5.0-14-3_all.deb
aptitude hold sun-java5-bin
aptitude hold sun-java5-jre

Thanks to #debian

posted by John  # 8:57:00 AM

Wednesday, May 28, 2008

Stitching images with ImageMagick 

From: http://studio.imagemagick.org/pipermail/magick-users/2002-July/003925.html

Simplified:

If you want to join images side by side:


[ AA.jpg ][ AB.jpg ][ AC.jpg ]


use:


convert +append AA.jpg AB.jpg AC.jpg row_A.png


NB: If they're not photos, you'll want the output to be PNG so it's not lossy.

When you want to join the rows the +append becomes -append like so:


[ row_A.png ]
[ row_B.png ]
[ row_C.png ]



convert -append row_A.png row_B.png row_C.png all_rows.png

posted by John  # 9:35:00 AM

Tuesday, April 29, 2008

Converting seconds to Hours, Minutes & Seconds 

It's amazing how many different approaches to doing this you can find on the web.

Some of them are really tortured and inefficient!

These are the tightest two I've found:


#!/usr/bin/perl
#
#
#
use warnings;
use strict;

my $time = time % 86400;

#
# http://www.perlmonks.org/?node_id=101511
#
printf "%02d:%02d:%02d\n",(gmtime $time)[2,1,0];

#
# http://www.perlmonks.org/?node_id=101548
#
printf "%02d:%02d:%02d\n", ($time/3600)%24, ($time/60)%60, $time%60;


To convert the other way, an easy way is to use POSIX mktime:


#!/usr/bin/perl

use warnings;
use strict;

use POSIX qw(mktime);

my $day = "2008-05-28";
my ($d_year, $d_mon, $d_mday) = split /-/, $day;

my $secs = mktime(0, 0, 0, $d_mday, $d_mon-1, $d_year-1900);


posted by John  # 12:45:00 AM

Wednesday, April 02, 2008

Showing a function in ksh 

If you need to see the contents of a function in ksh...


$ typeset -f [FUNCTION_NAME]


if you do typeset -f by itself it will list all of the defined functions.

posted by John  # 3:56:00 PM

Monday, March 24, 2008

Sharing your X desktop via VNC 

When getting set up to share my Linux X desktop, I found to my temporary confusion, that unlike vncserver on Windows, which of course shares your existing desktop, the vncserver program for X is designed to start a new instance of an X server (possibly even blind to the person on the machine) and share *that* rather sharing your existing desktop, which is probably what you usually need to do!

To share your existing X desktop via VNC requires another tool called x0vncserver.

As far as I know this is only available with vnc4 (realvnc) and not with tightvnc.

To share my desktop, the first thing I needed to do was to create a password file for the incoming user to authenticate against:


$ vncpasswd .vnc/passwd
Password:
Verify:


The .vnc directory didn't need to exist already, it creates it for you.


$ ll .vnc/
total 12
drwxr-xr-x 2 john john 4096 Mar 20 15:28 .
drwxr-xr-x 52 john john 4096 Mar 20 15:28 ..
-rw------- 1 john john 8 Mar 20 15:28 passwd


It only seems to use the first 8 characters, and then saves that as obfuscated binary data.

Once you have the password file you can launch x0vncserver against it:


$ x0vncserver PasswordFile=.vnc/passwd

Thu Mar 20 15:33:32 2008
main: XTest extension present - version 2.2
main: Listening on port 5900


and it is ready to accept incoming connections :o)

If the incoming user is using tightvnc or another client that does not support the vnc4 protocol extensions, then you need to tell it to run in vnc3.3 compatibility mode:


$ x0vncserver Protocol3.3 PasswordFile=.vnc/passwd


You can also get usage help from x0vncserver by running it with any args it doesn't understand:


$ x0vncserver .

posted by John  # 1:36:00 PM

Friday, March 07, 2008

suspend to disk on low battery... 

I found out why my machine was shutting down at low battery and why I couldn't get it to suspend to disk instead...

Fixed now :o)

You need to look at these files:


/etc/powersave/battery


I changed these values:


BATTERY_WARNING="10"
BATTERY_LOW="5"
BATTERY_CRITICAL="0"


And in:


/etc/powersave/events


I now have these:


EVENT_BATTERY_LOW="notify"
EVENT_BATTERY_CRITICAL="notify john_suspend_to_disk"


NB: I put john in the name so it would stick out like a sore thumb when I do a diff if dpkg ever asks me about changed config files on an upgrade and I'll know it's my own modification, and so it didn't conflict with or get overwritten by a provided script.

I created my own script to handle this:


/usr/lib/powersave/scripts/john_suspend_to_disk


which just has:


#!/bin/sh
#
#
#

sleep 10

/usr/sbin/s2disk

#
# You could use:
# echo -n disk > /sys/power/state
#


And I installed uswsusp which provides /usr/sbin/s2disk

Oh... I also set up a shell function to protect it, because I found I accidentally scrolled back through my shell history and hit enter on s2disk a couple of times ;o)


# type s2disk
s2disk is a function


I put this in my .bashrc:


s2disk ()
{
echo -e "Confirm you want to suspend: \c";
read OK;
if [ "$OK" = "y" ]; then
/usr/sbin/s2disk;
fi
}


What I *would* also like to add is a notify when the battery reaches 100% so I know to unplug my charger - I understand it's much better for the longevity of your battery if you don't leave it plugged in on full charge all the time and instead allow it to do full flat-charged-flat power cycles. I have a couple of laptops with useless batteries due to them having been left plugged in and running 24x7 for months or years on end - my Linux boxes rarely get shut down.

In an ideal world I'd like some device that plugged in between the charger plug and the laptop which I could drive from the OS to physically break the power connection when the battery gets to 100% - and not to reconnect it again until it's back to 0% (yes, I find with my reasonably new battery I can actually keep running it quite a while after it reaches "0%" - obviously 0% isn't dead flat - it's an arbitrary level set to give you a safety margin and still work when your battery is getting a bit knackered due to age.)

posted by John  # 9:09:00 PM

Wednesday, March 05, 2008

Problems installing vmplayer on Debian 

I downloaded VMware-player-2.0.2-59824.i386.rpm and converted it with alien.


# alien VMware-player-2.0.2-59824.i386.rpm --scripts


I had installed it before, then removed it to install vmware-server (because vmware-server complained that installing it caused file conflicts with vmplayer) and later removed vmware-server again and reinstalled vmplayer.

The bits left behind by vmware-server seem to break it...
The nice thing would be to find them and remove them, but I found a workaround.

When I first tried to install the player again I got error messages from some of the install scripts:


dpkg: error processing vmwareplayer_2.0.2-59825_i386.deb (--install):
subprocess pre-installation script returned error exit status 1
/var/lib/dpkg/tmp.ci/postrm: line 25: [: abort-install: integer expression expected
Errors were encountered while processing:
vmwareplayer_2.0.2-59825_i386.deb


So I backed up the deb file and built a copy of it with no scripts using:


# alien VMware-player-2.0.2-59824.i386.rpm


(and renamed that vmwareplayer_2.0.2-59825_i386.deb.no_scripts)

I was able to install it, but when I tried to run the player I found more hangovers of having had vmware-server installed:


$ vmplayer
Unable to load image-loading module: /build/mts/release/bora-59824/bora/build/release/ws/vmui/../libdir/libconf/lib/gtk-2.0/2.10.0/loaders/libpixbufloader-png.so: /build/mts/release/bora-59824/bora/build/release/ws/vmui/../libdir/libconf/lib/gtk-2.0/2.10.0/loaders/libpixbufloader-png.so: cannot open shared object file: No such file or directory


I made sure it was there:


$ locate libpixbufloader-png.so
/usr/lib/gtk-2.0/2.10.0/loaders/libpixbufloader-png.so


Eventually I found the solution was to run:


# /usr/bin/vmware-config.pl


but... that failed:


# /usr/bin/vmware-config.pl
Making sure services for VMware Player are stopped.

sh: /etc/init.d/vmware: No such file or directory
sh: /etc/init.d/vmware: No such file or directory
Unable to stop services for VMware Player

Execution aborted.



OK, so fake it:

Make a copy of /etc/init.d/vmware containing:


#!/bin/bash

echo $1


then:


# chmod +x /etc/init.d/vmware


Now run the config again:


# /usr/bin/vmware-config.pl
Making sure services for VMware Player are stopped.

status
stop

Configuring fallback GTK+ 2.4 libraries.

In which directory do you want to install the theme icons?
[/usr/share/icons]
...


and go through the rest of the config.

After this (if you have your correct compiler etc installed, you should find that vmplayer will start happily)

Once that works you will find you can now go back and over-install the copy of vmwareplayer_2.0.2-59825_i386.deb that DOES have scripts without it erroring, so you get your correct startup scripts etc...

Once you've reinstalled it you will again need to run


# /usr/bin/vmware-config.pl


one more time otherwise trying to run vmplayer will give you:


$ vmplayer
vmware is installed, but it has not been (correctly) configured
for this system. To (re-)configure it, invoke the following command:
/usr/bin/vmware-config.pl.


posted by John  # 3:54:00 PM

Tuesday, February 26, 2008

Overriding Recommends in aptitude install 


> When I try and install powersaved using aptitude it wants to install a whole
lot of kde stuff and I don't use kde (I use fluxbox) - am I right in thinking
this could be triggered by a number of programs recommending rather than one
depending on them? - if so - can I ignore the recommendations?
<gsimmons> JohnGH: You can instruct aptitude to not treat recommendations as dependencies by supplying the -R option.
> gsimmons: thank you



# aptitude install powersaved
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Reading task descriptions... Done
Building tag database... Done
The following NEW packages will be installed:
hdparm{a} kdelibs-data{a} kdelibs4c2a{a} kpowersave{a} libakode2{a} libarts1-akode{a} libarts1c2a{a}
libartsc0{a} libavahi-qt3-1{a} libdbus-qt-1-1c2{a} libjasper1{a} libmad0{a} libopenexr2ldbl{a}
libsamplerate0{a} libvorbisfile3{a} libxxf86misc1{a} menu-xdg{a} powersaved x11-xserver-utils{a}
0 packages upgraded, 19 newly installed, 0 to remove and 0 not upgraded.
Need to get 24.6MB of archives. After unpacking 74.6MB will be used.
Do you want to continue? [Y/n/?] - kpowersave
The following NEW packages will be installed:
hdparm{a} powersaved
The following packages are RECOMMENDED but will NOT be installed:
kpowersave
0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 502kB of archives. After unpacking 2400kB will be used.
Do you want to continue? [Y/n/?]
Writing extended state information... Done
Get:1 http://ftp.us.debian.org lenny/main hdparm 7.7-1 [66.9kB]
Get:2 http://ftp.us.debian.org lenny/main powersaved 0.14.0-8 [435kB]
Fetched 502kB in 3s (135kB/s)
Selecting previously deselected package hdparm.
(Reading database ... 55225 files and directories currently installed.)
Unpacking hdparm (from .../archives/hdparm_7.7-1_i386.deb) ...
Selecting previously deselected package powersaved.
Unpacking powersaved (from .../powersaved_0.14.0-8_i386.deb) ...
Setting up hdparm (7.7-1) ...
Setting up powersaved (0.14.0-8) ...
Reloading system message bus config...done.
Starting power management daemon: powersaved.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Writing extended state information... Done
Reading task descriptions... Done
Building tag database... Done

posted by John  # 11:42:00 AM

Thursday, February 21, 2008

How to set the default web browser in Evolution 

After reading from:





And trying it out...:



Read existing settings (recursively):



$ gconftool-2 -R /desktop/gnome/url-handlers

Backup settings to a file in case you want to roll back:



$ gconftool-2 -R /desktop/gnome/url-handlers > ~/.gconf/desktop/gnome/url-handlers.default

Get existing setting and type:



$ gconftool-2 -T -g /desktop/gnome/url-handlers/http/command

Set new setting and type



$ gconftool-2 -t string -s /desktop/gnome/url-handlers/http/command "x-www-browser %s"


Check new setting and type



$ gconftool-2 -T -g /desktop/gnome/url-handlers/http/command

Set new setting and type for https



$ gconftool-2 -t string -s /desktop/gnome/url-handlers/https/command "x-www-browser %s"

Done - try clicking on a link now... :-)


posted by John  # 6:36:00 PM

Read/Write NTFS support 

Just

# aptitude install ntfs-3g

and add something like:


/dev/sda1 /mnt/windows ntfs-3g uid=1000 0 0


to /etc/fstab

and you're done.

I've removed the old posts from 27/12/2004 and 06/08/2006 - this is much simpler and superceeds them.

posted by John  # 4:19:00 PM

Mounting VMWare vmdk files in Linux 

http://www.jameslittle.me.uk/how-to-mount-vmdk-files-in-linux/

http://ubuntuforums.org/archive/index.php/t-154738.html

posted by John  # 12:24:00 PM

Where does the VMWare Player "Recent Virtual Machines" list live? 

From
here:

The VMWare Player list of "Recent Virtual Machines" is stored in the file
[drive]:\Documents and Settings\[user]\Application Data\VMWare\preferences.ini



At the bottom of the file, there are entries like (where X is a sequential number):



pref.mruVMX.filename = "..."
pref.mruVMX.displayname = "..."


You can edit the entries here then save the file & start VMWare Player to see the changes. (VMWare Player saves its settings on exit, so will need to be closed before you make the changes, or they will be overwritten.)


posted by John  # 10:22:00 AM

Wednesday, February 20, 2008

grub error: /dev/sda does not have any corresponding BIOS drive 

On an IBM Thinkpad T43 the Debian install refused to install grub or LILO.



When I tried to run it from the command line:



# grub-install hd0

it returned:



/dev/sda does not have any corresponding BIOS drive.



I tried changing the partition sizes so that they ended on cylinder boundaries - wondering if it was that - but it wasn't.



What I needed to do to fix it was to go into the BIOS settings and disable the legacy floppy support (I don't have a floppy drive, so don't use that)



The clue that tipped me off was lots of repeating errors in dmesg about fd0 each time I ran grub-install - and the fact that it would go away and wait for 10 or 15 minutes or more.



The things I had to do were:



# mkdir /boot/grub

# grub-install --no-floppy --recheck hd0

( this created /boot/grub/device.map )



# update-grub

(this created /boot/grub/menu.lst)


posted by John  # 11:37:00 PM

Monday, February 18, 2008

DIY VMWare Linux Image 

Like using VMWare Player, but can't find the image you want, or they're too big to download quickly?

This is how to get a working Debian box in VMWare without burning a CD:

I found:

http://whiletrue.nl/blog/?p=61

and:

http://www.sqlservercentral.com/articles/Miscellaneous/useisoimageswithoutburningtodisk/1369/

All you need to do is download the blank VMX from:

http://www.mediafire.com/?bnvmhcghmw3


Which was originally from http://www.boonzaaijer.com/files/BlankVMX.zip
but I don't want to leech their bandwidth by hot linking - all of 4KB ;-)

Unzip it into a folder (I use C:\VMWare\BlankVMX here)

Download the ISO image you want to install from - I'm using the latest NetInst ISO image here:

http://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/i386/iso-cd/

and save it (I save it as C:\VMWare\

Change the "Other Linux 2.6.x kernel.vmx" file:

Change the lines:

ide1:0.present = "TRUE"
ide1:0.fileName = "auto detect"
ide1:0.deviceType = "cdrom-raw"

To read something like:

ide1:0.present = "TRUE"
ide1:0.fileName = "C:\VMWare\debian-testing-i386-businesscard.iso"
ide1:0.deviceType = "cdrom-image"

Then run the .vmx file - it will boot and launch into your install image as if it had booted off a burned copy of the install CD.

Further reading:

http://www.linux.com/feature/54411

posted by John  # 12:43:00 PM

Monday, September 17, 2007

corkscrew (not screwdriver!) 

I can't believe I didn't have a post about corkscrew already!

This is a great link:

http://www.mtu.net/~engstrom/ssh-proxy.php

install corkscrew via apt (synaptic/aptitude/apt-get whatever)

Edit your ~/.ssh/config file:


Host my.server my.other.server
    ProxyCommand corkscrew proxy.domain.com 8080 %h %p ~/.ssh/proxy_auth
    User remoteuser


in ~/.ssh/proxy_auth put:


username:password


It's a pain if you don't use the Host line because you have to comment the ProxyCommand line when you need to access a local machine (i.e. not through the proxy server)

Talking about proxies... a LONG time ago in another country (oots mon!) I used to use APS - I don't know if I'll need it again, but just in case, there it is.

posted by John  # 2:37:00 PM

Friday, September 14, 2007

VMware 

I'm using the Debian Etch image from here with VMware Player

To get it to use a UK keyboard mapping I needed to do

loadkeys uk

for console, and

dpkg-reconfigure xserver-xorg

for X.

You also might need to start networking manually, and I exported my proxy details:


export http_proxy="http://proxy-server:port/"


Then ran synaptic - NICE - hadn't used it before.
Upgraded to a 686 kernel from the 486 one, stripped out all the gnome packages and put in fluxbox and wdm instead - it's much faster now.

I also did this

dhclient kept overwriting /etc/resolv.conf so I added this to /etc/dhcp/dhclient.conf


supersede domain-name-servers ns1-ip-address, ns2-ip-address;
supersede domain-name "domain.com";


as per one of the answers here: http://forums.debian.net/viewtopic.php?t=7239

posted by John  # 4:02:00 PM

Tuesday, August 28, 2007

Perl scalar assignment 

The difference between:


my $var = EXPRESSION;


and


my ($var) = EXPRESSION;


is in whether EXPRESSION returns an array...

Of course in list context an array produces a list of the items in the array, but in scalar context it produces the number of items in the array...

By putting the parentheses around the scalar you are populating an array, and $var is asking for the first element of EXPRESSION if it returns a list, so:


#!/usr/bin/perl

use warnings;
use strict;

my @array = ('a', 'b', 'c');

my $var1 = @array;

my ($var2) = @array;

print "var1: [$var1]\nvar2: [$var2]\n";


returns:


var1: [3]
var2: [a]


Thus if your expression unexpectedly returns an array you at least get some useful value rather than a mysterious number. :-)

posted by John  # 8:26:00 PM

Thursday, August 23, 2007

Dumping all param values with mod_perl 

It's as simple as:




use strict;
use CGI ( );

my $cgi = new CGI;
print $cgi->header('text/plain');
print "DEBUG:\n", join('', map({"$_: [".$cgi->param($_)."]\n"} $cgi->param)), $/;


From: http://modperlbook.org/html/ch10_01.html#pmodperl-CHP-10-EX-11


posted by John  # 9:45:00 AM

Tuesday, August 21, 2007

Using netcat to run a port listener. 

If you want to have a port listening on a machine just so another host can test connecting to it (e.g. you want to see whether your "Connection refused" message is caused by your socket application failing to serve, or if it is serving but the connection is being blocked by a firewall)...

First make sure that the application that would normally listen to that port is stopped, then run up netcat:

nc -l -p 1234

where 1234 is the port you want to listen on...

Now from the other host:

telnet hostname.domain.com 1234

where hostname.domain.com is the machine you're running netcat on.

This is a failure:

$ telnet hostname.domain.com 1234
Trying 10.11.12.13...
telnet: Unable to connect to remote host: Connection refused

This is a successful connection:

$ telnet hostname.domain.com
Trying 10.11.12.13...
Connected to hostname.domain.com (10.11.12.13).
Escape character is '^]'.

If you get a connection then the network probably isn't the problem...

Once you're connected you can then either use ^D (<Ctrl-d>) to get out, or use ^] (<Ctrl-]>) to get a telnet prompt, then type close:

$ telnet hostname.domain.com
Trying 10.11.12.13...
Connected to hostname.domain.com (10.11.12.13).
Escape character is '^]'.
^]

telnet> close
Connection closed.

posted by John  # 1:28:00 PM

Monday, August 20, 2007

Permanently setting font and theme for gvim 

To set the font permanently:

set guifont=Fixed\ 9

or try:


set gfn=fixed
set guifont=courier\ 8


( see http://www.troubleshooters.com/linux/vifont.htm )
( nice: http://www.proggyfonts.com/ )

To set the colour scheme permanently use:

colorscheme

In your .vimrc

(or color )

When in command mode type :help colorscheme for some help on this subject.

and:

syntax on

to make use of it.

(or:)


" have syntax highlighting in terminals which can display colours:
" > if has('syntax') && (&t_Co > 2)
syntax on
" > endif


I also have a post on toggling search highlighting...


Tuesday, August 14, 2007

How do I find the version of my current (running) bash or ksh shell? 

If you just want to check from the command line:
bash --version
is OK, but that's not interactive - if you do that you're starting a new bash
which isn't necessarily the same version the current shell instance.

ksh:

In ksh you can display the version of the shell interactively by typing ^V

bash:

In bash you can do ^X^V (C-x C-v)

NB:
This works in set -o emacs.
If like me you prefer to live in the set -o vi world you may need to change to set -o emacs to check it and then back again.

There are also the BASH_VERSINFO array and BASH_VERSION variables

BASH_VERSINFO is immutable so you should be able to rely on it,
but BASH_VERSION could be set somewhere else so don't rely on it.

http://www.gnu.org/software/bash/manual/bashref.html#SEC110
has:

display-shell-version (C-x C-v)
Display version information about the current instance of Bash.

(thanks to jm_ on #debian for help with the research)

posted by John  # 10:36:00 AM

Monday, August 13, 2007

How to change the Theme in Firefox 

Problem:

You have found a cool Firefox theme on the web and want to download and try it,
but have never used another theme in Firefox before...

You download it and can install it OK, but now how the heck do you switch it on?

You go to Google and search and up comes spam in the form of a www.surveymonkey.com survey, ever so helpfully titled "Firefox Theme Tutorial" asking questions like:

1. Describe your experience with Firefox Themes.
-> I only use the default because I can't figure out how to change them.

2. Would you be interested in a detailed step by step how to guide for (*snip*) Firefox themes?

3. Would you be willing to pay for this guide?

4. How much would you be willing, if any, to pay for this guide?

Just damn cruel when that's the only thing that's in your face when you're looking for help!


OK, so you go to Help in Firefox and search for "theme"... you get:

Add-ons (extensions and themes)
Switching Themes
Using a High Contrast Theme


Hmm... "Switching Themes" is clearly the one I need... *click*:

Switching Themes

To switch between your installed themes, select the Themes panel, select the
theme of your choice, and click its Use Theme button. You need to
restart Firefox for changes to take effect.

Oh great... so I just need to select the Themes panel...
Click "Tools -> Options" - nope, not in there...
Check all the other menus:
File (didn't really think it would be there)
Edit (why would it be there?)
View (COULD be there... nope)
Tools (SHOULD be there, but can't see anything about themes)

the really helpful (NOT!) bit is that without scrolling backwards and forwards in the help page
there's no indication of where you FIND this "Themes panel"!

So after a bit more Googling I went to Intranet Exploder and tried out some of the YouTube tutorials...
(I don't install Flash in my Firefox - because I prefer not to have flash spam in pages...
the only time I start up IE is for something I *need* that uses Flash,
or for broken pages I have to use for work that don't validate and won't work in Firefox)

Yay! the answer \o/
http://youtube.com/watch?v=NvU4D-Buseo
http://youtube.com/watch?v=kykO8J0XA5c
http://youtube.com/watch?v=JjnCIRO9Jg4

I don't think I'd ever used YouTube to learn something technical before - but it certainly works!

In summary - the Themes are Add-ons - as are Extensions...
so the "Themes panel" is found under "Tools -> Add-ons"

I hadn't looked in there because I use Tools -> Add-ons quite regularly (for Extensions)
so didn't bother to look in there because I didn't remember noticing the Themes panel icon before.

posted by John  # 7:12:00 PM

Thursday, March 01, 2007

Accessing sshfs with Thunar 

I mounted a directory using sshfs:


sshfs user@host: /mnt/host


and found that while I could cd into it and ls it and do things with the files fine... Thunar (and Gentoo) didn't seem to know it existed.

I found the answer was to use -o allow_other when mounting the fuse-filesystem.


sshfs user@host: /mnt/host -o allow_other


all better :o)

posted by John  # 8:20:00 PM

Monday, February 19, 2007

bzip2 errors running apt-get update 

I kept getting an error like this running apt-get update (I'm pretty sure it was immediately following adding a new line to /etc/apt/sources.list):


Get:5 http://ftp.debian.org etch/main Sources [1222kB]
79% [4 Packages bzip2 3911680] [5 Sources 50355/1222kB 4%] 25.2kB/s
46sbzip2: Data integrity error when decompressing.
Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

Err http://ftp.debian.org etch/main Packages
Sub-process bzip2 returned an error code (2)
Fetched 5616kB in 1m32s (60.6kB/s)
Reading package lists... Done


That wasn't my actual screen scrape - that's Brian May's off Google... because mine scrolled out of my history before I thought to grab it... but...

What I did was to comment out the sources in /etc/apt/sources.list that were erroring, then re-ran apt-get update again, and it worked OK.

After I'd finished the update I uncommented the lines and re-ran apt-get update and it worked fine.

posted by John  # 12:26:00 PM

Wednesday, December 06, 2006

Oracle escape characters... 

...need to be declared:

http://www.dba-oracle.com/tips_oracle_escape_characters.htm

posted by John  # 1:19:00 PM

Thursday, November 30, 2006

Determining which package(s)/product(s) own(s) a file on Solaris 

You can do:

pkgchk -l -p /full/path/name

Or grep for the filename in /var/sadm/install/contents

posted by John  # 7:52:00 PM

Monday, November 27, 2006

Recording macros in vim 

http://www.vim.org/tips/tip.php?tip_id=144

posted by John  # 4:28:00 PM

Friday, November 10, 2006

Installing Solaris packages to a remote machine from a local CD 

If you put the Solaris CD in the drive on a Windows machine it doesn't read the CD filesystem correctly.
You will see directories and files with DOS (i.e. 8.3) filenames:
(created under Cygwin on Windows XP):

# tar tvf SUNWi1cs.windows.tar
-r-xr-xr-x 18403/10545 0 Aug 31 23:24 2000 SUNWi1cs/
-r-xr-xr-x 18403/10545 0 Aug 31 23:24 2000 SUNWi1cs/ARCHIVE/
-r--r--r-- 18403/10545 18457 Nov 24 20:55 1999 SUNWi1cs/ARCHIVE/NONE
-r-xr-xr-x 18403/10545 0 Aug 31 23:24 2000 SUNWi1cs/INSTALL/
-r--r--r-- 18403/10545 59 Oct 14 10:59 1999 SUNWi1cs/INSTALL/COPYRIGH
-r--r--r-- 18403/10545 1935 Nov 24 20:55 1999 SUNWi1cs/INSTALL/I_NONE
-r--r--r-- 18403/10545 829 Aug 31 23:09 2000 SUNWi1cs/PKGINFO
-r--r--r-- 18403/10545 889 Aug 31 23:09 2000 SUNWi1cs/PKGMAP
-r-xr-xr-x 18403/10545 0 Aug 31 23:24 2000 SUNWi1cs/RELOC/
-r-xr-xr-x 18403/10545 0 Aug 31 23:24 2000 SUNWi1cs/RELOC/USR/
-r-xr-xr-x 18403/10545 0 Aug 31 23:24 2000 SUNWi1cs/RELOC/USR/LIB/
-r-xr-xr-x 18403/10545 0 Aug 31 23:24 2000 SUNWi1cs/RELOC/USR/LIB/LOCALE/
-r-xr-xr-x 18403/10545 0 Aug 31 23:24 2000 SUNWi1cs/RELOC/USR/LIB/LOCALE/ISO_8859/
-r-xr-xr-x 18403/10545 0 Nov 24 20:55 1999 SUNWi1cs/RELOC/USR/LIB/LOCALE/ISO_8859/LC_CTYPE/
-r-xr-xr-x 18403/10545 0 Aug 31 23:24 2000 SUNWi1cs/RELOC/USR/OPENWIN/
-r-xr-xr-x 18403/10545 0 Aug 31 23:24 2000 SUNWi1cs/RELOC/USR/OPENWIN/LIB/
-r-xr-xr-x 18403/10545 0 Aug 31 23:24 2000 SUNWi1cs/RELOC/USR/OPENWIN/LIB/LOCALE/
-r-xr-xr-x 18403/10545 0 Nov 24 20:55 1999 SUNWi1cs/RELOC/USR/OPENWIN/LIB/LOCALE/ISO8859_/

If you have a Mac, that will read the CDs fine :o)
(and I expect Linux will too)

(Created on an iMac):

# tar tvf SUNWi1cs.tar
drwxr-xr-x 0/1 0 Aug 31 15:24 2000 SUNWi1cs/
drwxr-xr-x 0/10 0 Aug 31 15:24 2000 SUNWi1cs/archive/
-rw-r--r-- 0/10 18457 Nov 24 12:55 1999 SUNWi1cs/archive/none
drwxr-sr-x 0/10 0 Aug 31 15:24 2000 SUNWi1cs/install/
-rwxr-xr-x 0/10 59 Oct 14 02:59 1999 SUNWi1cs/install/copyright
-rw-r--r-- 0/10 1935 Nov 24 12:55 1999 SUNWi1cs/install/i.none
-rw-r--r-- 0/1 829 Aug 31 15:09 2000 SUNWi1cs/pkginfo
-rw-r--r-- 0/1 889 Aug 31 15:09 2000 SUNWi1cs/pkgmap
drwxr-sr-x 0/10 0 Aug 31 15:24 2000 SUNWi1cs/reloc/
drwxr-sr-x 0/10 0 Aug 31 15:24 2000 SUNWi1cs/reloc/usr/
drwxr-sr-x 0/10 0 Aug 31 15:24 2000 SUNWi1cs/reloc/usr/lib/
drwxr-sr-x 0/10 0 Aug 31 15:24 2000 SUNWi1cs/reloc/usr/lib/locale/
drwxr-sr-x 0/10 0 Aug 31 15:24 2000 SUNWi1cs/reloc/usr/lib/locale/iso_8859_1/
drwxr-sr-x 0/10 0 Nov 24 12:55 1999 SUNWi1cs/reloc/usr/lib/locale/iso_8859_1/LC_CTYPE/
drwxr-sr-x 0/10 0 Aug 31 15:24 2000 SUNWi1cs/reloc/usr/openwin/
drwxr-sr-x 0/10 0 Aug 31 15:24 2000 SUNWi1cs/reloc/usr/openwin/lib/
drwxr-sr-x 0/10 0 Aug 31 15:24 2000 SUNWi1cs/reloc/usr/openwin/lib/locale/
drwxr-sr-x 0/10 0 Nov 24 12:55 1999 SUNWi1cs/reloc/usr/openwin/lib/locale/iso8859-1/


I needed SUNWi1cs and SUNWi15cs which are on Software CD 1 of 2 on Solaris 8
which are required for installing the Oracle 10.2.0.1 client...

On the Mac


I put the CD in the drive on the Mac

I then did a 'mount' to see where the CD was mounted:

hostname:~ john$ mount
/dev/disk0s10 on / (local, journaled)
devfs on /dev (local)
fdesc on /dev (union)
<volfs> on /.vol
automount -nsl [335] on /Network (automounted)
automount -fstab [345] on /automount/Servers (automounted)
automount -static [345] on /automount/static (automounted)
afp_2lYWSz0UiuFX000009000000-6.2e000003 on /Volumes/ast (nodev, nosuid, mounted by john)
afp_2lYWSz0UiuFX000009000000-5.2e000004 on /Volumes/EtherShare (nodev, nosuid, mounted by john)
/dev/disk1s0 on /Volumes/SOL_8_1000_SPARC (local, nodev, nosuid, read-only)

Change directory into the Product directory:

hostname:~ john$ cd /Volumes/SOL_8_1000_SPARC/Solaris_8/Product/

List the packages you need to see they're there...

hostname:/Volumes/SOL_8_1000_SPARC/Solaris_8/Product john$ ls -ld SUNWi1cs SUNWi15cs
drwxr-xr-x 5 root daemon 2048 31 Aug 2000 SUNWi15cs
drwxr-xr-x 5 root daemon 2048 31 Aug 2000 SUNWi1cs

Tar up the packages to a writable directory (i.e. outside the CD):

hostname:/Volumes/SOL_8_1000_SPARC/Solaris_8/Product john$ tar cvf ~/SUNWi15cs.tar SUNWi15cs
SUNWi15cs/
SUNWi15cs/archive/
SUNWi15cs/archive/none
SUNWi15cs/install/
SUNWi15cs/install/copyright
SUNWi15cs/install/i.none
SUNWi15cs/pkginfo
SUNWi15cs/pkgmap
SUNWi15cs/reloc/
SUNWi15cs/reloc/usr/
SUNWi15cs/reloc/usr/lib/
SUNWi15cs/reloc/usr/lib/locale/
SUNWi15cs/reloc/usr/lib/locale/iso_8859_15/
SUNWi15cs/reloc/usr/lib/locale/iso_8859_15/LC_CTYPE/
SUNWi15cs/reloc/usr/openwin/
SUNWi15cs/reloc/usr/openwin/lib/
SUNWi15cs/reloc/usr/openwin/lib/locale/
SUNWi15cs/reloc/usr/openwin/lib/locale/iso8859-15/
SUNWi15cs/reloc/usr/openwin/lib/locale/iso8859-15/OW_FONT_SETS/
SUNWi15cs/reloc/usr/openwin/lib/locale/iso8859-15/print/
hostname:/Volumes/SOL_8_1000_SPARC/Solaris_8/Product john$ tar cvf ~/SUNWi1cs.tar SUNWi1cs
SUNWi1cs/
SUNWi1cs/archive/
SUNWi1cs/archive/none
SUNWi1cs/install/
SUNWi1cs/install/copyright
SUNWi1cs/install/i.none
SUNWi1cs/pkginfo
SUNWi1cs/pkgmap
SUNWi1cs/reloc/
SUNWi1cs/reloc/usr/
SUNWi1cs/reloc/usr/lib/
SUNWi1cs/reloc/usr/lib/locale/
SUNWi1cs/reloc/usr/lib/locale/iso_8859_1/
SUNWi1cs/reloc/usr/lib/locale/iso_8859_1/LC_CTYPE/
SUNWi1cs/reloc/usr/openwin/
SUNWi1cs/reloc/usr/openwin/lib/
SUNWi1cs/reloc/usr/openwin/lib/locale/
SUNWi1cs/reloc/usr/openwin/lib/locale/iso8859-1/

Go to that directory and list the files:

hostname:/Volumes/SOL_8_1000_SPARC/Solaris_8/Product john$ cd
hostname:~ john$ ls -l SUNW*
-rw-r--r-- 1 john staff 30720 10 Nov 15:31 SUNWi15cs.tar
-rw-r--r-- 1 john staff 40960 10 Nov 15:31 SUNWi1cs.tar

Copy the files to the Solaris machine:

hostname:~ john$ scp *.tar solarisbox:
john@solarisbox's password:
SUNWi15cs.tar 100% 30KB 2.8MB/s 00:00
SUNWi1cs.tar 100% 40KB 3.5MB/s 00:00

Now on the Solaris machine...


Move the tars somewhere:

# mkdir packages
# mv SUNW*.tar packages/
# cd packages
# ls -l SUNW*.tar
-rw-r--r-- 1 jharrison cascade 30720 Nov 10 15:32 SUNWi15cs.tar
-rw-r--r-- 1 jharrison cascade 40960 Nov 10 15:32 SUNWi1cs.tar

Unpack the tar files:

# tar xvf SUNWi15cs.tar
x SUNWi15cs, 0 bytes, 0 tape blocks
x SUNWi15cs/archive, 0 bytes, 0 tape blocks
x SUNWi15cs/archive/none, 7825 bytes, 16 tape blocks
x SUNWi15cs/install, 0 bytes, 0 tape blocks
x SUNWi15cs/install/copyright, 59 bytes, 1 tape blocks
x SUNWi15cs/install/i.none, 1935 bytes, 4 tape blocks
x SUNWi15cs/pkginfo, 724 bytes, 2 tape blocks
x SUNWi15cs/pkgmap, 1303 bytes, 3 tape blocks
x SUNWi15cs/reloc, 0 bytes, 0 tape blocks
x SUNWi15cs/reloc/usr, 0 bytes, 0 tape blocks
x SUNWi15cs/reloc/usr/lib, 0 bytes, 0 tape blocks
x SUNWi15cs/reloc/usr/lib/locale, 0 bytes, 0 tape blocks
x SUNWi15cs/reloc/usr/lib/locale/iso_8859_15, 0 bytes, 0 tape blocks
x SUNWi15cs/reloc/usr/lib/locale/iso_8859_15/LC_CTYPE, 0 bytes, 0 tape blocks
x SUNWi15cs/reloc/usr/openwin, 0 bytes, 0 tape blocks
x SUNWi15cs/reloc/usr/openwin/lib, 0 bytes, 0 tape blocks
x SUNWi15cs/reloc/usr/openwin/lib/locale, 0 bytes, 0 tape blocks
x SUNWi15cs/reloc/usr/openwin/lib/locale/iso8859-15, 0 bytes, 0 tape blocks
x SUNWi15cs/reloc/usr/openwin/lib/locale/iso8859-15/OW_FONT_SETS, 0 bytes, 0 tape blocks
x SUNWi15cs/reloc/usr/openwin/lib/locale/iso8859-15/print, 0 bytes, 0 tape blocks
# tar xvf SUNWi1cs.tar
x SUNWi1cs, 0 bytes, 0 tape blocks
x SUNWi1cs/archive, 0 bytes, 0 tape blocks
x SUNWi1cs/archive/none, 18457 bytes, 37 tape blocks
x SUNWi1cs/install, 0 bytes, 0 tape blocks
x SUNWi1cs/install/copyright, 59 bytes, 1 tape blocks
x SUNWi1cs/install/i.none, 1935 bytes, 4 tape blocks
x SUNWi1cs/pkginfo, 829 bytes, 2 tape blocks
x SUNWi1cs/pkgmap, 889 bytes, 2 tape blocks
x SUNWi1cs/reloc, 0 bytes, 0 tape blocks
x SUNWi1cs/reloc/usr, 0 bytes, 0 tape blocks
x SUNWi1cs/reloc/usr/lib, 0 bytes, 0 tape blocks
x SUNWi1cs/reloc/usr/lib/locale, 0 bytes, 0 tape blocks
x SUNWi1cs/reloc/usr/lib/locale/iso_8859_1, 0 bytes, 0 tape blocks
x SUNWi1cs/reloc/usr/lib/locale/iso_8859_1/LC_CTYPE, 0 bytes, 0 tape blocks
x SUNWi1cs/reloc/usr/openwin, 0 bytes, 0 tape blocks
x SUNWi1cs/reloc/usr/openwin/lib, 0 bytes, 0 tape blocks
x SUNWi1cs/reloc/usr/openwin/lib/locale, 0 bytes, 0 tape blocks
x SUNWi1cs/reloc/usr/openwin/lib/locale/iso8859-1, 0 bytes, 0 tape blocks

List the files:

# ls -l
total 144
drwxr-xr-x 5 root other 512 Aug 31 2000 SUNWi15cs
-rw-r--r-- 1 jharrison cascade 30720 Nov 10 15:32 SUNWi15cs.tar
drwxr-xr-x 5 root other 512 Aug 31 2000 SUNWi1cs
-rw-r--r-- 1 jharrison cascade 40960 Nov 10 15:32 SUNWi1cs.tar

Now you can ddd the packages, using the directory you untarred the package directories into as the directory for pkgadd to search for packages:

# pkgadd -d .

The following packages are available:
1 SUNWi15cs X11 ISO8859-15 Codeset Support
(sparc) 2.0,REV=1999.12.09.13.36
2 SUNWi1cs X11 ISO8859-1 Codeset Support
(sparc) 2.0,REV=1999.11.24.17.23

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: <Enter>

Processing package instance <SUNWi15cs> from </export/home/john/packages>

X11 ISO8859-15 Codeset Support
(sparc) 2.0,REV=1999.12.09.13.36
Copyright 2000 Sun Microsystems, Inc. All rights reserved.
Using </> as the package base directory.
## Processing package information.
## Processing system information.
8 package pathnames are already properly installed.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.

The following files are already installed on the system and are being
used by another package:
/usr <attribute change only>
/usr/lib <attribute change only>
/usr/openwin <attribute change only>
/usr/openwin/lib/locale/iso8859-15/Compose
/usr/openwin/lib/locale/iso8859-15/OW_FONT_SETS/OpenWindows.fs
/usr/openwin/lib/locale/iso8859-15/OWfontpath
/usr/openwin/lib/locale/iso8859-15/XLC_LOCALE
/usr/openwin/lib/locale/iso8859-15/print/prolog.ps

Do you want to install these conflicting files [y,n,?,q] y
## Checking for setuid/setgid programs.

This package contains scripts which will be executed with super-user
permission during the process of installing this package.

Do you want to continue with the installation of <SUNWi15cs> [y,n,?] y

Installing X11 ISO8859-15 Codeset Support as <SUNWi15cs>

## Installing part 1 of 1.

Installation of <SUNWi15cs> was successful.

Processing package instance <SUNWi1cs> from </export/home/john/packages>

X11 ISO8859-1 Codeset Support
(sparc) 2.0,REV=1999.11.24.17.23
Copyright 2000 Sun Microsystems, Inc. All rights reserved.
Using </> as the package base directory.
## Processing package information.
## Processing system information.
9 package pathnames are already properly installed.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.

The following files are already installed on the system and are being
used by another package:
/usr/lib/locale/iso_8859_1 <attribute change only>
/usr/lib/locale/iso_8859_1/LC_CTYPE <attribute change only>
/usr/openwin/lib/locale/iso8859-1/Compose
/usr/openwin/lib/locale/iso8859-1/xomEuro.so.2

Do you want to install these conflicting files [y,n,?,q] y
## Checking for setuid/setgid programs.

This package contains scripts which will be executed with super-user
permission during the process of installing this package.

Do you want to continue with the installation of <SUNWi1cs> [y,n,?] y

Installing X11 ISO8859-1 Codeset Support as <SUNWi1cs>

## Installing part 1 of 1.

Installation of <SUNWi1cs> was successful.

The following packages are available:
1 SUNWi15cs X11 ISO8859-15 Codeset Support
(sparc) 2.0,REV=1999.12.09.13.36
2 SUNWi1cs X11 ISO8859-1 Codeset Support
(sparc) 2.0,REV=1999.11.24.17.23

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: q
#

Done! :o)

posted by John  # 3:47:00 PM

Problem installing DBD::Oracle on Solaris 

I'm having problems compiling DBD::Oracle on Solaris 7.
I've run a make realclean, then perl Makefile.PL, then when I run the make I get:


cp Oracle.pm blib/lib/DBD/Oracle.pm
cp mkta.pl blib/lib/DBD/mkta.pl
cp oraperl.ph blib/lib/oraperl.ph
cp dbdimp.h blib/arch/auto/DBD/Oracle/dbdimp.h
cp ocitrace.h blib/arch/auto/DBD/Oracle/ocitrace.h
cp Oraperl.pm blib/lib/Oraperl.pm
cp Oracle.h blib/arch/auto/DBD/Oracle/Oracle.h
cp mk.pm blib/arch/auto/DBD/Oracle/mk.pm
cp lib/DBD/Oracle/GetInfo.pm blib/lib/DBD/Oracle/GetInfo.pm
/usr/local/bin/perl -p -e "s/~DRIVER~/Oracle/g" /usr/local/lib/perl5/site_perl/5.8.3/sun4-solaris/auto/DBI/Driver.xst > Oracle.xsi
/usr/local/bin/perl /usr/local/lib/perl5/5.8.3/ExtUtils/xsubpp -typemap /usr/local/lib/perl5/5.8.3/ExtUtils/typemap -typemap typemap Oracle.xs > Oracle.xsc && mv Oracle.xsc Oracle.c
gcc -B/usr/ccs/bin/ -c -I/app/oracle/product/8.1.5/rdbms/demo -I/app/oracle/product/8.1.5/rdbms/demo -I/app/oracle/product/8.1.5/rdbms/public -I/app/oracle/product/8.1.5/plsql/public -I/app/oracle/product/8.1.5/network/public -I/usr/local/lib/perl5/site_perl/5.8.3/sun4-solaris/auto/DBI -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O -DVERSION=\"1.19\" -DXS_VERSION=\"1.19\" -fPIC "-I/usr/local/lib/perl5/5.8.3/sun4-solaris/CORE" -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"8.1.5.0\" Oracle.c
gcc -B/usr/ccs/bin/ -c -I/app/oracle/product/8.1.5/rdbms/demo -I/app/oracle/product/8.1.5/rdbms/demo -I/app/oracle/product/8.1.5/rdbms/public -I/app/oracle/product/8.1.5/plsql/public -I/app/oracle/product/8.1.5/network/public -I/usr/local/lib/perl5/site_perl/5.8.3/sun4-solaris/auto/DBI -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O -DVERSION=\"1.19\" -DXS_VERSION=\"1.19\" -fPIC "-I/usr/local/lib/perl5/5.8.3/sun4-solaris/CORE" -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"8.1.5.0\" dbdimp.c
dbdimp.c: In function `ora_db_login6':
dbdimp.c:456: warning: unused variable `rsize'
dbdimp.c: In function `ora2sql_type':
dbdimp.c:2487: error: `SQLT_TIMESTAMP_LTZ' undeclared (first use in this function)
dbdimp.c:2487: error: (Each undeclared identifier is reported only once
dbdimp.c:2487: error: for each function it appears in.)
make: *** [dbdimp.o] Error 1
/usr/local/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
make had returned bad status, install seems impossible
Failed during this command:
PYTHIAN/DBD-Oracle-1.19.tar.gz : make NO

Versions:

# uname -a
SunOS apollo 5.7 Generic_106541-42 sun4u sparc SUNW,Ultra-Enterprise

# perl -V
Summary of my perl5 (revision 5.0 version 8 subversion 3) configuration:
Platform:
osname=solaris, osvers=2.7, archname=sun4-solaris
uname='sunos 5.7 generic_patch sun4u sparc sunw,ultra-1 solaris '
config_args='-Dcc=gcc -B/usr/ccs/bin/'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc -B/usr/ccs/bin/', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O',
cppflags='-fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='3.3.2', gccosandvers='solaris2.7'
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='gcc -B/usr/ccs/bin/', ldflags =' -L/usr/local/lib '
libpth=/usr/local/lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc
perllibs=-lsocket -lnsl -ldl -lm -lc
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'


Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under solaris
Compiled at Feb 9 2004 03:12:16
@INC:
/usr/local/lib/perl5/5.8.3/sun4-solaris
/usr/local/lib/perl5/5.8.3
/usr/local/lib/perl5/site_perl/5.8.3/sun4-solaris
/usr/local/lib/perl5/site_perl/5.8.3
/usr/local/lib/perl5/site_perl
.

# gcc --version
gcc (GCC) 3.4.6
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

In case it was the compiler version I rolled back to gcc 3.3.2
But with gcc 3.3.2 I got the same error.

This file I found on Google references SQLT_TIMESTAMP_LTZ:
http://ftp.emini.dk/pub/php/win32/dev/php_build/oci805/include/ocidfn.h

I found this file in:

(ORACLE)/rdbms/demo/ocidfn.h


I upgraded to 10.2.0.1 and that worked.
In trying to get it working with 8.1.5 I tried adding more directories to CFLAGS
This didn't work.
What did get it to compile was hacking dbdimp.c and adding:


#include
#define SQLT_TIMESTAMP_LTZ 232 /* TIMESTAMP WITH LOCAL TZ */


but I think that's a bit of a nasty hack...

posted by John  # 2:53:00 PM

Problem installing libiconv-1.9.2-sol7-sparc-local 


# <b>pkgadd -d libiconv-1.9.2-sol7-sparc-local</b>

The following packages are available:
1 SMCliconv libiconv
(sparc) 1.9.2

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:

Processing package instance <SMCliconv> from </tmp/download/libiconv-1.9.2-sol7-sparc-local>

libiconv
(sparc) 1.9.2

Current administration requires that a unique instance of the
<SMCliconv> package be created. However, the maximum number of
instances of the package which may be supported at one time on the
same system has already been met.

No changes were made to the system.

posted by John  # 9:48:00 AM

Thursday, November 09, 2006

Can't install PathTools on Cygwin 


user@hostname /opt/pkg/cpan/build/PathTools-3.23
$ make install
Cannot forceunlink /usr/lib/perl5/5.8/cygwin/auto/Cwd/Cwd.dll: Permission denied at /usr/lib/perl5/5.8/File/Find.pm line 907
make: *** [pure_perl_install] Error 13
user@hostname /opt/pkg/cpan/build/PathTools-3.23
$ ll /usr/lib/perl5/5.8/cygwin/auto/Cwd/Cwd.dll
-rw-rw-rw-+ 1 user group 9216 Dec 30 2005 /usr/lib/perl5/5.8/cygwin/auto/Cwd/Cwd.dll
user@hostname /opt/pkg/cpan/build/PathTools-3.23
$ cd /usr/lib/perl5/5.8/cygwin/auto/Cwd/
user@hostname /usr/lib/perl5/5.8/cygwin/auto/Cwd
$ ll
total 16
drwxrwx---+ 2 user group 0 Nov 8 10:27 .
drwxrwx---+ 39 user group 0 Nov 9 09:30 ..
-rwxr-x---+ 1 user group 0 Dec 30 2005 Cwd.bs
-rw-rw-rw-+ 1 user group 9216 Dec 30 2005 Cwd.dll
-rwxr-x---+ 1 user group 2596 Dec 30 2005 libCwd.dll.a
user@hostname /usr/lib/perl5/5.8/cygwin/auto/Cwd
$ mv Cwd.dll Cwd.dll.orig
`Cwd.dll' -> `Cwd.dll.orig'
user@hostname /usr/lib/perl5/5.8/cygwin/auto/Cwd
$ ll
total 16
drwxrwx---+ 2 user group 0 Nov 9 11:37 .
drwxrwx---+ 39 user group 0 Nov 9 09:30 ..
-rwxr-x---+ 1 user group 0 Dec 30 2005 Cwd.bs
-rw-rw-rw-+ 1 user group 9216 Dec 30 2005 Cwd.dll.orig
-rwxr-x---+ 1 user group 2596 Dec 30 2005 libCwd.dll.a
user@hostname /usr/lib/perl5/5.8/cygwin/auto/Cwd
$ cd -
/opt/pkg/cpan/build/PathTools-3.23
user@hostname /opt/pkg/cpan/build/PathTools-3.23
$ make install
Installing /usr/lib/perl5/5.8/cygwin/auto/Cwd/Cwd.dll
Installing /usr/lib/perl5/5.8/cygwin/auto/Cwd/libCwd.dll.a
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/lib/perl5/5.8/cygwin/Cwd.pm
Installing /usr/lib/perl5/5.8/cygwin/File/Spec.pm
Installing /usr/lib/perl5/5.8/cygwin/File/Spec/Cygwin.pm
Installing /usr/lib/perl5/5.8/cygwin/File/Spec/Epoc.pm
Installing /usr/lib/perl5/5.8/cygwin/File/Spec/Functions.pm
Installing /usr/lib/perl5/5.8/cygwin/File/Spec/Mac.pm
Installing /usr/lib/perl5/5.8/cygwin/File/Spec/OS2.pm
Installing /usr/lib/perl5/5.8/cygwin/File/Spec/Unix.pm
Installing /usr/lib/perl5/5.8/cygwin/File/Spec/VMS.pm
Installing /usr/lib/perl5/5.8/cygwin/File/Spec/Win32.pm
Writing /usr/lib/perl5/5.8/cygwin/auto/Cwd/.packlist
Appending installation info to /usr/lib/perl5/5.8/cygwin/perllocal.pod
user@hostname /opt/pkg/cpan/build/PathTools-3.23
$

posted by John  # 11:46:00 AM

Solaris OpenSSH motd displays twice... 

http://www.informit.com/articles/article.asp?p=100574&seqNum=4&rl=1

http://www.brandonhutchinson.com/Installing_OpenSSH.html

posted by John  # 10:23:00 AM

cpan broken: Writing Makefile for ... NOT OK 

http://comments.gmane.org/gmane.os.cygwin.perl/64

http://www.cpanforum.com/threads/502

Reconfigure CPAN
http://sial.org/howto/perl/life-with-cpan/#s5

posted by John  # 9:26:00 AM

Wednesday, November 01, 2006

Highlight part of an image in GIMP 

Take your image (maybe a screenshot)...

Select the part you want to highlight.
Duplicate the image layer.
do Select -> Invert
Double click on the forground colour to get the colour selection dialogue.
Type "c0c0c0" in the "HTML Notation" box.
Click OK in the colour selection dialogue.
Select the copy layer
Flood fill the bottom one with c0c0c0.
Select each layer in the layer dialogue and change the blending mode to multiply or to darken only (which ever looks best)

posted by John  # 10:31:00 AM

Friday, October 27, 2006

Background Halo in GIMP 

Sooo easy!!!

Downloaded this:

http://web.archive.org/www.marcreichelt.de/spezial/tuxgrafiken/tux_huge.png

Read this:

http://www.gimp-tutorials.com/tutorial/Drop-Shadow-in-gimp-138.html
( http://gug.sunsite.dk/tutorials/cmarshall2/ )

Reanamed Background Layer to Tux

Created a new "Background" layer and filled it with black.

Duplicated Tux layer

Moved "Tux copy" behind Tux

With Tux copy layer selected:

Did ^A changed fill to Whole Selection, filled with white.

Copied layer

Turned off "Keep Transparency"

Right-Click, and choose Filters->Blur->Gaussian Blur (IIR) (50x50)

Paste your white copy over it again.

Anchor pasted layer

Filters->Repeat Gaussian Blur

Paste white copy (rinse & repeat 4 or 5 times and the halo will grow)

If you do it without the paste the halo will not be so bright and will thin a bit.


http://img127.imageshack.us/my.php?image=tuxvectmap02inkscape04re0.png

http://www.upload2.net/page/download/xVO6K9n03c8meZc/tux_huge_halo.xcf.html

posted by John  # 3:04:00 PM

Thursday, October 19, 2006

Bin the annoying blue junk & enjoy chatting at the Sametime... 

UPDATE: This used to be about installing GAIM (later Pidgin) with Meanwhile support - Meanwhile (the Sametime plugin) is now built in to Pidgin so you don't need to install it seperately... so this is now about how to get spell checking with Pidgin.

Have to use Sametime at work and fed up with it crashing or closing windows and losing your conversation history with no log when you accidentally brush the [Esc] key???

Hey there chataholics, this could be just what you've been looking for!
Take a chunk of Pidgin (which you used to know as Gaim)
Mix in a good sized quantity of GTK+
Sprinkle with a small pinch of Aspell and presto, ready to serve!

Currently available for free from your local store:
pidgin 2.0.2
GTK+ 2.10.13 rev a
Aspell

NB: For Aspell this time I installed the full installer, then the English dictionary... it spell checks British spelling correctly.

posted by John  # 2:18:00 PM

GIMP pwnz j00! 

This is the same image:

-rwx------ 1 gbr02703 mkpasswd 1823914 Oct 19 21:02 gimp.psd
-rwx------ 1 gbr02703 mkpasswd 983037 Oct 19 21:05 gimp.xcf

The XCF file is half the size of the PSD but still handles layers.
(I don't know what PSD can do that it can't - I'll have to read on that)

Irfanview did save the PSD as a smaller PNG than GIMP did...
but then when I opened the Irfanview PNG in GIMP and saved that as a new png
GIMP it made it even SMALLER than Irfanview had!

-rwx------ 1 gbr02703 mkpasswd 324875 Oct 19 21:02 gimp.png
-rwx------ 1 gbr02703 mkpasswd 299304 Oct 19 21:46 irfanview.png
-rwx------ 1 gbr02703 mkpasswd 299283 Oct 19 21:47 irfanview_gimp.png

posted by John  # 2:18:00 PM

Thursday, October 12, 2006

Adobe Reader offline installer 

The Adobe Reader download page only offers you to download a 521Kb installer stub which downloads the rest of the installation off the net.

That isn't great if you're behind a proxy server that it won't authenticate with!

I found this page which says that a full installer can be downloaded from here:


Adobe Acrobat 7.0.8 Standalone Full Installer 20.3 MB


posted by John  # 4:07:00 PM

Wednesday, October 11, 2006

vim search highlighting 



Don't you hate that when you do a search in vim and all the results are highlighted, but they're highlighted in such a colour scheme that you can't see what that text is anymore? (white on yellow anyone?) ...sometimes you want to turn it off in a hurry.

...toggling syntax highlighting:

I have this in my ~/.vimrc now:


:colorscheme johngh

"
" Have <F2> toggle search match highlighting and report the change:
"

nnoremap <F2> :set hls! hls?<CR>

"
" Define colors that are different enough to be noticeable
" and clear enough to be visible...
"
hi search guifg=LightBlue guibg=White " gvim
hi search ctermfg=LightBlue ctermbg=White " console/terminal vim


There are different ways to express this, I've used the shortest I've found here.
As far as I know they mean the same thing, but I've also seen/tried:


nnoremap \th :set invhls hls?<CR>


and...


map <F2> :set hlsearch!<CR>


I presume "!" is the same as "inv", and that it means "toggle/invert the value of..."

I presume "?" means "show the value of..."

Originally from TipID 14


" have \th ("toggle highlight") toggle highlighting of search matches, and
" report the change:
nnoremap \th :set invhls hls?<CR>


NB: the \th is entered literally as \+t+h

\(letters) is nice to use in vim for mapping things, because \ is not used otherwise.
It's nice to keep v free for on-the-fly mappings...
<F2> is free, so let's use that here :o)

posted by John  # 7:35:00 PM

Thursday, October 05, 2006

apt-get public key errors 

If you get public key errors like this when you do apt-get update

# apt-get update
Get:1 http://debian.tu-bs.de sid Release.gpg [189B]
Hit http://debian.tu-bs.de sid Release
Err http://debian.tu-bs.de sid Release
Get:2 http://debian.tu-bs.de sid Release [24.3kB]
Ign http://debian.tu-bs.de sid Release
Ign http://debian.tu-bs.de sid/nx Packages/DiffIndex
Hit http://debian.tu-bs.de sid/nx Packages
Fetched 24.5kB in 0s (42.1kB/s)
Reading package lists... Done
W: GPG error: http://debian.tu-bs.de sid Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY FB1A399A71409CDF
W: You may want to run apt-get update to correct these problems

As root, using the key that it says is not available, do this:

# gpg --keyserver wwwkeys.eu.pgp.net --recv-keys FB1A399A71409CDF
gpg: requesting key 71409CDF from hkp server wwwkeys.eu.pgp.net
gpg: key 71409CDF: public key "Stefan Lippers-Hollmann (http://www.kanotix.com) <s.l-h@gmx.de>" imported
gpg: Total number processed: 1
gpg:               imported: 1

This can be abbreviated:

# gpg --keyserver wwwkeys.eu.pgp.net --recv 71409CDF

# gpg --list-keys 71409CDF
pub   1024D/71409CDF 2004-11-11
uid                  Stefan Lippers-Hollmann (http://www.kanotix.com) <s.l-h@gmx.de>

# gpg --export 71409CDF > 71409CDF.gpg

# apt-key add ./71409CDF.gpg
OK

# apt-key list 71409CDF
/etc/apt/trusted.gpg
--------------------
pub   1024D/71409CDF 2004-11-11
uid                  Stefan Lippers-Hollmann (http://www.kanotix.com) <s.l-h@gmx.de>

The next time you run

# apt-get

the messages are gone.

Cleaning up...


You probably don't want to leave the key in your public keyring ( /root/.gnupg/pubring.gpg )
You can remove it like this:

# gpg --delete-key FB1A399A71409CDF
gpg (GnuPG) 1.4.5; Copyright (C) 2006 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.


pub 1024D/71409CDF 2004-11-11 Stefan Lippers-Hollmann (http://www.kanotix.com) <s.l-h@gmx.de>

Delete this key from the keyring? (y/N) y


Also see this post.

If you want to be lazy you can use this as a shell script and call it with the ID of the key you want to import:


#!/bin/bash

if [ "$1" = "" ]
then
cat <<EOT >&1
Usage: $0 PUBKEY_ID_TO_IMPORT
Run apt-get update and copy the key ID from the error line like:
W: GPG error: http://www.debian.org etch Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0123456789ABCDEF
e.g.:
$0 0123456789ABCDEF
EOT
exit 1
fi
gpg --keyserver wwwkeys.eu.pgp.net --recv-keys $1
gpg --list-keys $1
gpg --export $1 > $1.gpg
apt-key add ./$1.gpg
apt-key list
gpg --delete-key $1

posted by John  # 8:53:00 PM

Perl in-line edits... 

If you'd like to be able to run a command like:

$ inline "TEXT TO REPLACE" "REPLACE WITH" filename

Make a shell script with this:

#!/bin/sh

MATCH_STRING=$1
REPLACE_WITH=$2
EDIT_FILE=$3

perl -pi.$$ -e "s{${MATCH_STRING}}{${REPLACE_WITH}}g" ${EDIT_FILE}

It will rename the files to the original filename with the current process ID on the back, and leave an edited copy in the new file.

Alternatively instead of the process ID, a timestamp (of the time now) might be more useful.

You could use:

DATE=$(date +'%Y%m%d%H%M%S')

perl -pi.${DATE} -e "s{${MATCH_STRING}}{${REPLACE_WITH}}g" ${EDIT_FILE}

or perhaps more usefully, for a timestamp based on the last modified time of the file before editing:

TIMESTAMP=$(date '+%Y%m%d%H%M%S' -r ${EDIT_FILE})

Like: 20061005151552

You might want the unix timestamp of the last modified time of the file:

TIMESTAMP=$(date +%s -r ${EDIT_FILE})

or

TIMESTAMP=$(stat -c %Y ${EDIT_FILE})

Both give: 1160057752

then:

perl -pi.${TIMESTAMP} -e "s{${MATCH_STRING}}{${REPLACE_WITH}}g" ${EDIT_FILE}

posted by John  # 4:55:00 PM

Monday, October 02, 2006

NX on Etch 

Sorry if this is a bit random... I'm tired! I'll try and fix it later.

From home before I left:

ssh -R 1234:localhost:22 mywebserver.net

and left something running that kept the session active (and therefore alive)


vi /etc/apt/sources.list

Added the text from here...

# In case you only want NX related packages,
# the following repository lines are sufficient:
deb http://debian.tu-bs.de/project/kanotix/unstable/ sid nx
deb-src http://debian.tu-bs.de/project/kanotix/unstable/ sid nx

then did:

apt-get update
apt-get upgrade

For good luck I did this, because I'd been messing around with it over the past 3-4 days:

apt-get remove --purge nxserver nxnode nxclient nxlibs nxlibs-dev nxdesktop nxagent nxagent-dev

Then I did:

apt-cache search NoMachine | less
apt-get install nxagent

And downloaded and installed the other .debs from nomachine.com

wget -N http://64.34.161.181/download/2.1.0/Linux/FE/nxserver_2.1.0-7_i386.deb
wget -N http://64.34.161.181/download/2.1.0/Linux/nxclient_2.1.0-6_i386.deb
wget -N http://64.34.161.181/download/2.1.0/Linux/nxmanager_2.1.0-5_i386.deb
wget -N http://64.34.161.181/download/2.1.0/Linux/nxnode_2.1.0-7_i386.deb
wget -N http://kanotix.com/files/debian/pool/main/f/freenx/freenx_0.4.4+0.4.5-4_all.deb

dpkg -i nxclient_2.1.0-6_i386.deb
dpkg -i nxnode_2.1.0-7_i386.deb
dpkg -i nxmanager_2.1.0-5_i386.deb
dpkg -i nxserver_2.1.0-7_i386.deb

less /usr/NX/var/log/install

/etc/init.d/nxserver start
apt-get install nxserver freenx
nxsetup --setup-nomachine-key
nxserver --status



# dpkg --list | grep nx
ii freenx 0.4.4+0.4.5-4 The FreeNX application/thin-client server ba
ii nxagent 1.4.92+1.5.0-11 NoMachine NX - nesting X server with roundtr
ii nxclient 2.1.0-6 NX Client
ii nxlibs 1.4.92+1.5.0-11 NoMachine NX - common agent libraries
ii nxmanager 2.1.0-5 NX Server Manager.
ii nxnode 2.1.0-7 NX Server Node
ii nxserver 2.1.0-7 NX Server


I run fluxbox:

# which fluxbox
/usr/bin/fluxbox

I did this in the client:

General tab:

Host: localhost
Port: 1234
Desktop:
Dropdowns: Unix [v] Custom [v]
[Settings]
Application
Run the following command: /usr/bin/fluxbox
Options
New virtual desktop
[OK]
ADSL
Display: Available area

Advanced tab:
[x]Enable SSL encryption of all traffic.

PuTTY:

Connection
SSH Tunnels
L1234:localhost:1234

Once you get NX working you may find this useful: How to setup international keyboard in X Window with Xmodmap and XKB

posted by John  # 7:53:00 PM

Friday, September 22, 2006

vim command line history... 

If you're on a Red Hat box (or some other lowly being...) and call vi and :ver tells you you're in vim, but when you try and get your command line history with Up-Arrow and it just says /<Up> .. have a look at :ver again and you will probably see:

~
~
~
~
~
~
~
:ver
VIM - Vi IMproved 6.3 (2004 June 7, compiled Feb 7 2005 08:07:43)
Included patches: 1-21, 23-24, 26, 28-34, 36-37, 39-40, 42-43, 45-46
Compiled by <bugzilla@redhat.com>
Tiny version without GUI. Features included (+) or not (-):
-arabic -autocmd -balloon_eval -browse +builtin_terms -byte_offset -cindent
-clientserver -clipboard -cmdline_compl -cmdline_hist -cmdline_info -comments
-cryptv -cscope -dialog -diff -digraphs -dnd -ebcdic -emacs_tags -eval
-ex_extra -extra_search -farsi -file_in_path -find_in_path -folding -footer
+fork() -gettext -hangul_input +iconv -insert_expand -jumplist -keymap -langmap
-libcall -linebreak -lispindent -listcmds -localmap -menu -mksession
-modify_fname -mouse -mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm
-mouse_xterm +multi_byte -multi_lang -netbeans_intg -osfiletype -path_extra
-perl -printer -python -quickfix -rightleft -ruby -scrollbind -signs
-smartindent -sniff -statusline -sun_workshop -syntax -tag_binary
-tag_old_static -tag_any_white -tcl +terminfo -termresponse -textobjects -title
-toolbar -user_commands -vertsplit -virtualedit -visual -viminfo -vreplace
+wildignore -wildmenu -windows +writebackup -X11 -xfontset -xim -xsmp
-xterm_clipboard -xterm_save
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation: i386-redhat-linux-gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pi
pe -march=i386 -mcpu=i686 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
Linking: i386-redhat-linux-gcc -L/usr/local/lib -o vim -ltermcap -lacl

If you read http://www.vim.org/htmldoc/cmdline.html#cmdline-history it says:

{not available when compiled without the |+cmdline_hist| feature}

The answer is to plant more trees.... (whoops, sorry Billy!)
Try "which vi" and if you're on Red Hat chances are you'll see:

user@host:~: which vi
/bin/vi
user@host:~: which vim
/usr/bin/vim
user@host:~: ll $(which vi) $(which vim)
-rwxr-xr-x 1 root root 473964 Feb 7 2005 /bin/vi
-rwxr-xr-x 1 root root 1966604 Feb 7 2005 /usr/bin/vim

do

alias vi='/usr/bin/vim'

And all your L337N355 will come flooding back to you!

posted by John  # 2:32:00 PM

Thursday, September 21, 2006

What's the IP of $HOSTNAME 


perl -MSocket -e 'print inet_ntoa((gethostbyname '$HOSTNAME')[4]), $/;'

posted by John  # 10:05:00 PM

Dumping a webpage in text... 

$ lwp-request -o text http://www.aotea.org/john/

This will probably need a few CPAN modules added to work, but the layout is nice and clean - it doesn't line up table cells.

$ elinks -no-numbering -no-references -dump http://www.aotea.org/john/

posted by John  # 9:06:00 PM

hostname in localhost line in /etc/hosts 

DON'T DO IT!

the /etc/hosts file in the Slackware installer image still has this in it:


# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server. Just add the names, addresses
# and any aliases to this file...
#
# By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
# should NEVER be named with the name of the machine. It causes problems
# for some (stupid) programs, irc and reputedly talk. :^)
#

# For loopbacking.
127.0.0.1 localhost
# This next entry is technically wrong, but good enough to get TCP/IP apps
# to quit complaining that they can't verify the hostname on a loopback-only
# Linux box.
127.0.0.1 slackware.example.net slackware

# End of hosts.


Brain-dead Red Hat does this when you install


127.0.0.1 hostname localhost.localdomain localhost


Eeagh! WRONG!

posted by John  # 4:12:00 PM

Tuesday, September 05, 2006

Printing to PDF 

Either or both of these:

PrimoPDF

CutePDF

I have found that the printer driver you chose makes a massive difference to the finished product, some are OK, and some are really crap.

The best driver I have found so far on XP is the latest built-in HP Postscript driver, (HP color LaserJet 9500 PostScript driver) which you can download from here

It's 11MB though, and you can get a 3.1MB one from here

I tried the ones from here or here but they don't want to let you print to the virtual local ports - either LP1 or COM1 or network printers - nothing else - I don't know how to seperate the renderer from the printing interface. :o(

The others I tried were not as good, particularly the "QMS ColorScript 1000 Level 1" which I found suggested here was truly pants!

The "Apple Color LaserWriter 12/600" which was recommended in the CutePDF FAQ was OK, but not great, the main body text of the first page I wanted to print came out in a rusty brown, not in black.

If you are making your PDFs from Word documents and want a PDF which has clickable links (like the index and web links) I'd recommend installing Open Office and exporting to PDF from OOWriter.

posted by John  # 1:07:00 PM

Useful applications 

Dia rocks...
(I've tried WinFIG and it sucks)

GIMP for Windows & GTK+

posted by John  # 12:59:00 PM

Monday, September 04, 2006

PuTTY for Cygwin terminal 

If you have to use Cygwin, this ROCKS :o)

http://gecko.gc.maricopa.edu/~medgar/puttycyg/

posted by John  # 8:42:00 PM

Tuesday, August 29, 2006

bash directory history 

These two scripts give you a directory history in bash:

cdhist.bash

acd_func.sh
(or here)

posted by John  # 11:27:00 AM

Monday, August 21, 2006

Tahoma font legally... 

As far as I remember reading, Tahoma font is not allowed to be distributed by itself so that you could use it in Linux like you can with some other Windows True Type fonts...

As far as I know if you already have Windows installed on your machine with Tahoma font in it (it's *CORE* in Windows XP) there's nothing against using the existing copy...


lrwxrwxrwx 1 root root 31 Apr 18 18:08 /usr/share/fonts/truetype/msttcorefonts/Tahoma.ttf -> /mnt/c/WINDOWS/Fonts/tahoma.ttf
lrwxrwxrwx 1 root root 10 Apr 18 18:16 /usr/share/fonts/truetype/msttcorefonts/tahoma.ttf -> Tahoma.ttf
lrwxrwxrwx 1 root root 15 Apr 18 18:17 /usr/share/fonts/truetype/msttcorefonts/tahomabd.ttf -> Tahoma_Bold.ttf
lrwxrwxrwx 1 root root 33 Apr 18 18:08 /usr/share/fonts/truetype/msttcorefonts/Tahoma_Bold.ttf -> /mnt/c/WINDOWS/Fonts/tahomabd.ttf
lrwxrwxrwx 1 root root 50 Apr 18 18:22 /var/lib/defoma/gs.d/dirs/fonts/Tahoma.ttf -> /usr/share/fonts/truetype/msttcorefonts/Tahoma.ttf
lrwxrwxrwx 1 root root 55 Apr 18 18:22 /var/lib/defoma/gs.d/dirs/fonts/Tahoma_Bold.ttf -> /usr/share/fonts/truetype/msttcorefonts/Tahoma_Bold.ttf
lrwxrwxrwx 1 root root 50 Apr 18 18:23 /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/Tahoma.ttf -> /usr/share/fonts/truetype/msttcorefonts/Tahoma.ttf
lrwxrwxrwx 1 root root 55 Apr 18 18:23 /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/Tahoma_Bold.ttf -> /usr/share/fonts/truetype/msttcorefonts/Tahoma_Bold.ttf



#!/bin/bash

WINDIR=/mnt/c/WINDOWS

# -rwxrwx--- 1 john john 355436 Jul 18 2004 /mnt/c/WINDOWS/Fonts/tahomabd.ttf
# -rwxrwx--- 1 john john 383140 Jul 18 2004 /mnt/c/WINDOWS/Fonts/tahoma.ttf
# -rwxrwx--- 1 john john 460728 Jul 18 2004 /mnt/c/WINDOWS/Fonts/micross.ttf

# lrwxrwxrwx 1 root root 31 Apr 18 18:08 /usr/share/fonts/truetype/msttcorefonts/Tahoma.ttf -> /mnt/c/WINDOWS/Fonts/tahoma.ttf
# lrwxrwxrwx 1 root root 10 Apr 18 18:16 /usr/share/fonts/truetype/msttcorefonts/tahoma.ttf -> Tahoma.ttf
# lrwxrwxrwx 1 root root 50 Apr 18 18:22 /var/lib/defoma/gs.d/dirs/fonts/Tahoma.ttf -> /usr/share/fonts/truetype/msttcorefonts/Tahoma.ttf
# lrwxrwxrwx 1 root root 50 Apr 18 18:23 /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/Tahoma.ttf -> /usr/share/fonts/truetype/msttcorefonts/Tahoma.ttf

# lrwxrwxrwx 1 root root 33 Apr 18 18:08 /usr/share/fonts/truetype/msttcorefonts/Tahoma_Bold.ttf -> /mnt/c/WINDOWS/Fonts/tahomabd.ttf
# lrwxrwxrwx 1 root root 15 Apr 18 18:17 /usr/share/fonts/truetype/msttcorefonts/tahomabd.ttf -> Tahoma_Bold.ttf
# lrwxrwxrwx 1 root root 55 Apr 18 18:22 /var/lib/defoma/gs.d/dirs/fonts/Tahoma_Bold.ttf -> /usr/share/fonts/truetype/msttcorefonts/Tahoma_Bold.ttf
# lrwxrwxrwx 1 root root 55 Apr 18 18:23 /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/Tahoma_Bold.ttf -> /usr/share/fonts/truetype/msttcorefonts/Tahoma_Bold.ttf

FONT=micross.ttf
UPPER=Micross.ttf

SOURCE=$WINDIR/Fonts/$FONT

MSTT_CORE_DIR=/usr/share/fonts/truetype/msttcorefonts

ln -sv $WINDIR/Fonts/$FONT $MSTT_CORE_DIR/$FONT
ln -sv $FONT $MSTT_CORE_DIR/$UPPER
ln -sv $MSTT_CORE_DIR/$FONT /var/lib/defoma/gs.d/dirs/fonts/$FONT
ln -sv $MSTT_CORE_DIR/$FONT /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/$FONT

fc-cache -fsv


Was that all?

posted by John  # 11:33:00 PM

Wednesday, August 09, 2006

Unix Review > The Open Road: Creating your own man pages 

Unix Review > The Open Road: Creating your own man pages

posted by John  # 10:51:00 AM

Wednesday, July 12, 2006

Perl:: at's Debugger 

ysth's post

At the top:


use constant DEBUG => $ENV{DEBUG};


or just:


use constant DEBUG => 1;


Then later:


printDebug("some message") if DEBUG;


or


DEBUG and printDebug("some message");


It's good if you want to hard wire the debug level by editing the script, but unfortunately this falls down when you want to use a variable to set it... say a command line flag... in this case, this will work:


use Getopt::Std;

getopts('v', \my %opts);

sub VERBOSE() { $opts{v} }

print "Message...\n" if VERBOSE;


Explanation and benchmark tests are in stefp's thread.

posted by John  # 9:41:00 AM

Sunday, July 09, 2006

Spyware 

Two nasties I've had to deal with in the last few months, both of which installed registry hooks into the Windows startup and Explorer launch so that they required Windows to load dlls which then locked them as system files, and they would sit there watching the registry to make sure that they re-added any registry entry you deleted, so you couldn't turn them off or remove them.

The only way to get around them in the end was to boot off an XP install CD or some other boot image that can write to NTFS file systems and remove the offending files from C:\Windows\System32 - generally the newest files in that directory.
(From time to time there are a number of files of exactly the same size and different time stamps = the spyware making clones of itself)

The two I've removed (off two different machines) were WinFixer and SysProtect.
Nasty little buggers.

Must-have toolbox for dealing with nasties:

AdAware Anti-Spyware
SpyBot S&D Anti-Spyware
ewido anti-spyware Anti-Spyware
AVG Free Free Anti-Virus
Sysinternals Process Explorer Kill bad processes.
Sysinternals Autoruns Clean out start-up entries for bad processes.
RegSeeker Clean your registry afterwards.

If you need a boot CD:

Trinity Rescue Kit (85MB)

Paragon NTFS for Linux NTFS for Linux trial version (includes a self-burning .exe - only 26.3MB to download)

NTFS driver for DOS (could work from boot floppy if you have a floppy drive. (Haven't tested this)

posted by John  # 12:40:00 AM

Sunday, June 04, 2006

How do I read the Volume ID of a CDROM under Linux? 

If you want to read a CDROM Volume ID under Linux (as set by 'mkisofs -V volID') (which Solaris & Windows can read, and Windows displays as the disk label) you can do:


# dd if=/dev/cdrom bs=1 skip=32808 count=32


Or do:


# dd if=/dev/cdrom bs=8 skip=4101 count=4

posted by John  # 6:18:00 AM

Saturday, February 18, 2006

Getting Skype installed properly... 

I got the up-to-date Skype package working, so I don't need to use the "Static binary tar.bz2 with Qt 3.2 compiled in" one...

I downloaded the latest version (currently skype_1.2.0.18-1_i386.deb) from here: http://www.skype.com/products/skype/linux/

If you try and install this you get:


# dpkg -i skype_1.2.0.18-1_i386.deb
dpkg - warning: downgrading skype from 1.2.0.18-2jgh to 1.2.0.18-1.
(Reading database ... 52930 files and directories currently installed.)
Preparing to replace skype 1.2.0.18-2jgh (using skype_1.2.0.18-1_i386.deb) ...
Unpacking replacement skype ...
dpkg: dependency problems prevent configuration of skype:
skype depends on libqt3c102-mt (>= 3:3.3.3.2); however:
Package libqt3c102-mt is not installed.
dpkg: error processing skype (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
skype


Which you can get around by doing:

dpkg --force-depends -i skype_1.2.0.18-1_i386.deb

but that's not nice.

This can be fixed by correcting the DEBIAN/control in the .deb file.
One way to do this is: download the .deb package, move it into a new directory
& cd into that directory, then do this:


mkdir skype
dpkg-deb --extract skype_1.2.0.18-1_i386.deb skype
dpkg-deb --control skype_1.2.0.18-1_i386.deb skype/DEBIAN


Now use your favorite editor to edit the Depends line:


vi skype/DEBIAN/control


I changed:

Version: 1.2.0.18-1

to:

Version: 1.2.0.18-2sg


and more importantly changed:

Depends: ... libqt3c102-mt ...

to:

Depends: ... libqt3-mt ...


I also added a menu entry like this:


cd skype
vi usr/share/menu/skype

add this to the file:

?package(skype):needs="X11" section="Apps/Net" title="Skype" command="/usr/bin/skype" icon="/usr/share/icons/skype.png"


Then you need to rebuild the DEBIAN/md5sums file so it knows about the menu file:
# find etc usr -type f -exec md5sum {} \; > DEBIAN/md5sums.new
# diff DEBIAN/md5sums DEBIAN/md5sums.new
36a37
> 6033460bf835d754b25451943db3e92f usr/share/menu/skype
# mv DEBIAN/md5sums.new DEBIAN/md5sums


Then cd back up a directory and rebuild the package:


cd ..
dpkg --build skype
mv skype.deb skype_1.2.0.18-2sg_i386.deb


That's it. Now you can install it:


dpkg -i skype_1.2.0.18-2sg_i386.deb


I found the basic of these instructions here: http://forum.skype.com/viewtopic.php?t=44138 and added a bit to it...

posted by John  # 8:27:00 PM

Friday, February 17, 2006

Soundcard again... 

Ages ago I recall finding that the ALSA drivers didn't work on the Tosh, so I was running OSS, but then when I upgraded to 2.6.15-1-686 they stopped... whether that was just because I didn't know to run alsaconf I don't know - but it *did* work fine on the Vaio.

debian-faq-wiki::UseSoundCard
had everything I needed to get ALSA going this time.

ALSA vs OSS

ALSA rocks! - now my Gaim has sound too I can hear when people login or out or send me messages... and my console beeps work :o)

Best of all... I can now use that *gorgeous* AlsaPlayer again... which lets you speed up and slow down and even reverse tracks!!! - crazy :o) great thing to have access to if you're getting bored with listening to your music collection!

posted by John  # 3:36:00 PM

Gaim spell check 

It seems there are quite a few dependencies to get this working, and the gaim package doesn't actually recommend the bits you need, so I had a look at the Vaio and a few looks with apt-cache search and ended up getting it working...

I *think* this is pretty much what you need:


gaim
(shock, horror!)
aspell
aspell-en
dictionaries-common
libgtkspell0

posted by John  # 12:00:00 PM

Friday, February 10, 2006

Installing XML::Simple 

http://www.cpanforum.com/threads/1473


cpan> install XML::Simple
Running install for module XML::Simple
Running make for G/GR/GRANTM/XML-Simple-2.14.tar.gz
Is already unwrapped into directory /root/.cpan/build/XML-Simple-2.14
Has already been processed within this session
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0,
'blib/lib', 'blib/arch')" t/*.t
# Package Version
# perl 5.8.7
# XML::Simple 2.14
# Storable 2.13
# XML::Parser Not Installed
# XML::SAX 0.13
# XML::NamespaceSupport 1.09
# XML::SAX::PurePerl 0.90 (default parser)
t/0_Config........ok
t/1_XMLin.........ok 1/122Unable to recognise encoding of this document at /usr/
local/share/perl/5.8.7/XML/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
t/1_XMLin.........NOK 32
# Failed test 'no warning issued (as expected)'
# in t/1_XMLin.t at line 380.
# got: 'Unable to recognise encoding of this document at /usr/local/sha
re/perl/5.8.7/XML/SAX/PurePerl/EncodingDetect.pm line 96.
# '
# expected: ''
t/1_XMLin.........ok 33/122Unable to recognise encoding of this document at /usr
/local/share/perl/5.8.7/XML/SAX/PurePerl/EncodingDetect.pm line 96.
t/1_XMLin.........NOK 38
# Failed test 'CDATA section parsed correctly'
# in t/1_XMLin.t at line 426.
# Structures begin differing at:
# $got->{cdata} = 'Hello, world!>'
# $expected->{cdata} = 'Hello, world!'
t/1_XMLin.........NOK 39
# Failed test 'CDATA section containing markup characters parsed correctly'
# in t/1_XMLin.t at line 432.
# Structures begin differing at:
# $got->{x} = 'one>two>'
# $expected->{x} = 'onetwo'
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96, line 1.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96, line 1.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96, line 1.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96, line 1.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96, line 1.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96, line 1.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96, line 1.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96, line 1.
t/1_XMLin.........NOK 122
# Failed test 'successfully read an SRT config file'
# in t/1_XMLin.t at line 1443.
# Structures begin differing at:
# $got->{pubpath}{test1}{title} = 'web_source -> web_target1'
# $expected->{pubpath}{test1}{title} = 'web_source -> web_target1'
# Looks like you failed 4 tests of 122.
t/1_XMLin.........dubious
Test returned status 4 (wstat 1024, 0x400)
DIED. FAILED tests 32, 38-39, 122
Failed 4/122 tests, 96.72% okay
t/2_XMLout........NOK 47
# Failed test 'generated document with escaping'
# in t/2_XMLout.t at line 302.
# Structures begin differing at:
# $got->{c} = '&C&'
# $expected->{c} = '&C&'
t/2_XMLout........ok 99/196Unable to recognise encoding of this document at /usr
/local/share/perl/5.8.7/XML/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
t/2_XMLout........ok 196/196# Looks like you failed 1 test of 196.
t/2_XMLout........dubious
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED test 47
Failed 1/196 tests, 99.49% okay (less 1 skipped test: 194 okay, 98.98%)
t/3_Storable......ok
t/4_MemShare......ok
t/5_MemCopy.......ok
t/6_ObjIntf.......ok
t/7_SaxStuff......ok
t/8_Namespaces....ok
t/9_Strict........ok 2/38Unable to recognise encoding of this document at /usr/l
ocal/share/perl/5.8.7/XML/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
Unable to recognise encoding of this document at /usr/local/share/perl/5.8.7/XML
/SAX/PurePerl/EncodingDetect.pm line 96.
t/9_Strict........ok
t/A_XMLParser.....skipped
all skipped: no XML::Parser
Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
t/1_XMLin.t 4 1024 122 4 3.28% 32 38-39 122
t/2_XMLout.t 1 256 196 1 0.51% 47
1 test and 1 subtest skipped.
Failed 2/11 test scripts, 81.82% okay. 5/454 subtests failed, 98.90% okay.
make: *** [test_dynamic] Error 255
/usr/bin/make test -- NOT OK
Running make install
make test had returned bad status, won't install without force


posted by John  # 8:10:00 PM

Thursday, February 09, 2006

tcpdump syntax 


/usr/sbin/tcpdump -A -s 65535 -i eth0 -l host $ME and host $IT

posted by John  # 12:00:00 AM

Wednesday, January 25, 2006

NFS errors... 


# umount /var/cache/apt/archives
Cannot MOUNTPROG RPC: RPC: Port mapper failure - RPC: Unable to receive
umount: /var/cache/apt/archives: device is busy


and


# mount /var/cache/apt/archives
mount: RPC: Remote system error - Connection refused


Hmmm... the NFS daemon was not running on server.

I did this on the server:


/etc/init.d/portmap start
/etc/init.d/nfs-kernerl-server start


After I had done this I got:


# umount /var/cache/apt/archives
Cannot MOUNTPROG RPC: RPC: Program not registered


and


# mount /var/cache/apt/archives
mount: RPC: Program not registered


I had to add an entry to /etc/hosts.allow on the server like this:


ssh sshd : ALL@ALL : ALLOW
ALL : 127.0.0.1 LOCAL : ALLOW
portmap : 192.168.254.0/255.255.255.0 : allow


then...


# umount /var/cache/apt/archives
umount: /var/cache/apt/archives: not mounted


YAY! got it!


# mount -v /var/cache/apt/archives
mount: uaine:/var/cache/apt/archives failed, reason given by server: Permission denied


Whoops! I had the wrong directory on the server in the /etc/fstab on the client machine...


# vi /etc/fstab
# mount -v /var/cache/apt/archives
uaine:/mnt/hda1/var/cache/apt/archives on /var/cache/apt/archives type nfs (rw,addr=192.168.254.6)



# mount
...
uaine:/mnt/hda1/var/cache/apt/archives on /var/cache/apt/archives type nfs (rw,addr=192.168.254.6)


All sorted :o)

posted by John  # 5:32:00 PM

Tuesday, January 17, 2006

Files with spaces in their names... 

If you want to process the output of find and some files have spaces in their names, you don't need to use double quotes...

find has the -print0 switch and xargs has the -0 (or --null) switch.


find . -type f -print0 | xargs -0 ls -l


posted by John  # 12:47:00 AM

Monday, January 09, 2006

Debian public key expired... 


Reading package lists... Done
W: GPG error: http://ftp.uk.debian.org testing Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 010908312D230C5F
W: You may want to run apt-get update to correct these problems


and something like this:


10 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Need to get 0B/14.7MB of archives.
After unpacking 557kB of additional disk space will be used.
Do you want to continue [Y/n]?
WARNING: The following packages cannot be authenticated!
  apt apt-utils libgimp2.0 gimp-svg gimp gimp-data
Install these packages without verification [y/N]?
E: Some packages could not be authenticated


This page explains it:

http://secure-testing-master.debian.net/

And this year (2006) while the link on the secure-testing page is still out of date, you can fix it with this:


gpg --keyserver subkeys.pgp.net --recv-keys 084750FC01A6D388A643D869010908312D230C5F
gpg --export 084750FC01A6D388A643D869010908312D230C5F | sudo apt-key add -


(thanks to #debian irc channel on freenode.net)

NB1: This will only work this year (2006) - because next year's key signiture will be different.

NB2: This has the side effect of adding the public key to root's keyring which you can see with:


gpg --list-keys


which gives:


pub   1024D/2D230C5F 2006-01-03 [expires: 2007-02-07]
uid                  Debian Archive Automatic Signing Key (2006)


You may want to remove it from there once you've imported it into apt, you can do this with:


gpg --delete-key 2D230C5F

posted by John  # 11:31:00 AM

Monday, November 28, 2005

Decimal to Binary 

Crazy...

I've always had access to Perl (well since I started using Linux in 1994) and yet I've laboured over writing things in C sometimes... like maths stuff! - fancy spending days writing and months tweaking a command line calculator program in C... now I have this *massive* perl script:


#!/usr/bin/perl -w
die "Usage: $0 MATHS\n" unless(@ARGV);for(@ARGV){s/x/*/g};
print eval(join('',@ARGV)),$/;


To convert a decimal number to binary in perl you could do:


unpack("B32", pack("N", $number));


and then chopping off the leading zeros... as per http://www.unix.org.ua/orelly/perl/cookbook/ch02_05.htm

... but TIMTOWTDI, you're better to use:


sprint("%08b", $number);

posted by John  # 3:56:00 PM

Wednesday, November 23, 2005

Multi line comments in Perl... 

How-can-I-comment-out-a-large-block-of-perl-code?

or even just...


=pod
blah
blah
blah
~
~
~
=cut


...from http://mail.pm.org/pipermail/nwarkansas-pm/2000-September/000001.html


serf 2005-11-23 14:02:41-05 is =pod ... =cut still OK? or is that deprecated?
serf 2005-11-23 14:03:28-05 I found it here
ysth 2005-11-23 14:08:50-05 serf that will confuse any pod parser trying to look for documentation interspersed with your code; =for comment...=end comment =cut is better


http://perldoc.perl.org/perlpod.html

posted by John  # 6:57:00 PM

Prompt... 

ksh:

if [ "$TERM" = "xterm" ]
then
       ESC=$(echo "\033]0;")
       BEL=$(echo "\a")
       MY_TTY="[`tty|sed 's/^\/dev\///g'`]"
       LOG_HOST="$LOGNAME@$(hostname):"
       PS1=$ESC$LOG_HOST'$PWD '$MY_TTY$BEL$LOG_HOST'$PWD '$MY_TTY"
\$ "
else
       PS1=$LOG_HOST'$PWD$ '
fi


bash:

case $TERM in
xterm )
       PS1="\e]0;\u@\h:\w [`tty`]\a\u@\h:\w [`tty`]\n\$ "
;;
* )
       PS1='\u@\h:\w\n\$ '
;;
esac

posted by John  # 3:01:00 PM

Tuesday, November 22, 2005

Supress count in isql 

To supress "X rows affected" from printing with isql, do:


set nocount on


before the select

posted by John  # 6:10:00 PM

Friday, November 18, 2005

Sybase TLI 

http://www.outlands.demon.co.uk/sybase/

posted by John  # 5:06:00 PM

Tuesday, November 08, 2005

Excel keyboard shortcuts... 

The one I wanted to know was to delete a cell (or a column or row)... because <Delete> just clears the cell contents...

The keyboard shortcut is <Ctrl--> (Control+Minus) (Hyphen)

http://www.ozgrid.com/Excel/ExcelKeyBoardShortcutKeys.htm

posted by John  # 10:37:00 AM

Monday, November 07, 2005

Replacing with ^M in vim 

If you want to remove ^M (<Ctrl-M> or Carriage Return) in vim (or vi) you can just do:


s/^M//g


To get the ^M use ^V^M

If you do


s/<TEXT>/^M/g


the <TEXT> is replaced with a newline character (i.e. ^J or \n) instead :o(

If you want to replace text with an actual ^M do:


s/<TEXT>/\^M/g


Of course if you're on Windows using gvim the ^V^M doesn't work, it's just the same as pressing -
on Windows you need to use CTRL-Q instead of CTRL-V to escape the special character on the ex command line or to do a blockwise visual selection

From the documentation:

(usr_24.txt)

Note:
On MS-Windows CTRL-V is used to paste text. Use CTRL-Q instead of
CTRL-V. On Unix, on the other hand, CTRL-Q does not work on some
terminals, because it has a special meaning.

(gui_w32.txt)
*CTRL-V-alternative* *CTRL-Q*
Since CTRL-V is used to paste, you can't use it to start a blockwise Visual
selection. You can use CTRL-Q instead. You can also use CTRL-Q in Insert
mode and Command-line mode to get the old meaning of CTRL-V. But CTRL-Q
doesn't work for terminals when it's used for control flow.


posted by John  # 4:52:00 PM

Saturday, October 29, 2005

Making a list of directories with perl... 


perl -e 'for(1..12){my $dir=sprintf("%02i ",$_);mkdir"2005/$dir"}'

posted by John  # 8:44:00 AM

Thursday, October 20, 2005

vi move line 

<ESC>:11m32<Enter>

will move line 11 to 32. :o)

(works in standard vi too)

<ESC>:11,15m32<Enter>

works too...

*just* found it by accident after all these years!
(thanks vim command history so I could see what I typed instead of 11,32!!!)

posted by John  # 5:34:00 PM

Wednesday, October 19, 2005

Perl conditional (colon) operator. 


printf "I have %d camel%s.\n", $n, $n == 1 ? "" : "s";


http://www.unix.org.ua/orelly/perl/prog3/ch03_16.htm

posted by John  # 3:35:00 PM

Thursday, October 13, 2005

NIS commands 


$ nisgrep username passwd.org_dir
username:ENCRYPTPASSWD:1000305537:10:User Name:/home/username:/bin/ksh:13063:1:63:14:::

$ getent passwd username
username:x:1000305537:10:User Name:/home/username:/bin/ksh

$ niscat -o '[name=username]passwd.org_dir'
Object Name : "passwd"
Directory : "org_dir.domain.com."
Owner : "username.domain.com."
Group : ""
Access Rights : ----r-----------
Time to Live : 12:0:0
Creation Time : Wed Aug 3 13:10:33 2005
Mod. Time : Fri Oct 7 10:39:27 2005
Object Type : ENTRY
Entry data of type passwd_tbl
[0] - [8 bytes] 'username'
[1] - [14 bytes] Encrypted data
[2] - [11 bytes] 'XXXXXXXXX'
[3] - [3 bytes] '10'
[4] - [14 bytes] 'User Name'
[5] - [14 bytes] '/home/username'
[6] - [9 bytes] '/bin/ksh'
[7] - [17 bytes] Encrypted data

posted by John  # 3:57:00 PM

Perl inline edit... 

http://www.rice.edu/web/perl-edit.html

posted by John  # 3:26:00 PM

autovivification 

exists => nasty...

if ( $HASH{'key1'}{'key2'} );

Will define $HASH{'key1'}

If you don't want to do that you need to do:

if ( $HASH{'key1'} && $HASH{'key1'}{'key2'} );

posted by John  # 11:44:00 AM

Thursday, March 10, 2005

PHP error... 

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /dirname/filename.php(000) : eval()'d code on line 3

put {} around the $_SERVER['VARIABLE'] like this: ${_SERVER['VARIABLE']}

posted by John  # 2:19:00 AM

Wednesday, March 09, 2005

awk bits... 

# List of logins


who | awk '{name[n++]=$1};END{for(i=1;i<=n;i++){printf name[i]" "}; print ""}'


# List of unique logged in users


who|awk '{w[$1]=$1};END{for(n in w)printf" "n}'

posted by John  # 8:38:00 PM

Tuesday, March 08, 2005

10 years and still counting... 

Crazy... 10 years at this now, and I'm still learning the basics...

Take a break ... command :o) ...


DATE=$(date +'%y%m%d')
for VER in $(seq -f %02g 99)
do
    if [ -f file_${DATE}-${VER}.tar -o -f file_${DATE}-${VER}.tar.gz ]
    then
        echo "file_${DATE}-${VER}.tar already exists..."
    else
        tar cvf file_${DATE}-${VER}.tar clean
        gzip -9 file_${DATE}-${VER}.tar
        break
    fi
done


Never needed it till now... but I was thinking... .o0(I need to break out... what would the command be?)

Or driving sed... instead of:


    sed 's/^ *//g' | grep .


how about:


    sed -n 's/^ *//g;/./p'


:o)

posted by John  # 11:05:00 PM

Monday, March 07, 2005

Very cute... 

I was wondering last night .oO(has anyone written a text editor in Perl?) - not an x app like ptked, but a console app... and yes of course they have...

http://ped.sourceforge.net/

- one of the monks has even done vi :o)
https://sourceforge.net/projects/vip
http://perlmonks.thepen.com/41736.html

Oh, and... http://ppt.perl.org/commands/ed/index.html

posted by John  # 2:29:00 AM

Sunday, March 06, 2005

Babygimp Homepage 

Babygimp Homepage

Yeah! - Just what I needed... the tool that's under Gimp...

I used to use Windows paintbrush, but more often than not I needed to save it to xpm and take it back to Linux and tweak it... now I can save it as xpm native :o) perfect... it's the tool for pixel tweaking.

posted by John  # 12:21:00 AM

Friday, March 04, 2005

De Morgan's Theorem... 

Does logic do your head in?


if(!condition1 | !condition2) equals if(!(condition1 & condition2))

And

if(!condition1 & !condition2) equals if(!(condition1 | condition2))

posted by John  # 4:16:00 PM

Perl multi-line match... 

davis gave me the answer nicely...


#!/usr/bin/perl

use warnings;
use strict;

local $/;
$_ = <DATA>;

$_ =~ s/<table>\n<tr>/<!-- TABLE START -->/i;

print;

__DATA__

<TABLE>
<TR>
<TD>



And also added:

you can ignore leading spaces with:


$_ =~ s/\s*]*>\n\s*/\n/ig

posted by John  # 8:00:00 AM

Wednesday, March 02, 2005

Missing header files... 


$ make hello
cc hello.c -o hello
hello.c:1:19: stdio.h: No such file or directory
hello.c:2:20: unistd.h: No such file or directory
hello.c: In function `main':
hello.c:89: error: `stdout' undeclared (first use in this function)
hello.c:89: error: (Each undeclared identifier is reported only once
hello.c:89: error: for each function it appears in.)
make: *** [hello] Error 1

# apt-get install libc6-dev

Hello, world!

:o)
(humming "the stripper"):

#!/bin/bash
/usr/bin/strip --remove-section=.comment --remove-section=.note --strip-all $@

posted by John  # 10:39:00 AM

Thursday, February 24, 2005

Debian Administration :: Mounting remote filesystems using SSH 

Debian Administration :: Mounting remote filesystems using SSH: "module-assistant install shfs"

Truely beautiful :o) and sooo easy!

posted by John  # 1:52:00 PM

Thursday, February 17, 2005

Need to update all of the CPAN modules on a server? 

If you are using the CPAN module within Perl, you can update all of the installed modules on your system using the command:


perl -MCPAN -e 'CPAN::Shell->install(CPAN::Shell->r)'


This forces CPAN to produce a list of all of the outdated modules on the machine and install them in one hit...

Not recommended for your average joe. you'll have to go over all of your module dependecies and check to see if updates break any of your live code.. still though there are instances where this can be useful.

Something else to think about... have a look here:


lrwxrwxrwx 1 root root 5 Feb 5 21:36 /usr/lib/perl/5.8 -> 5.8.4
drwxr-xr-x 5 root root 4096 Jan 30 2004 /usr/lib/perl/5.8.2
drwxr-xr-x 4 root root 4096 May 4 2004 /usr/lib/perl/5.8.3
drwxr-xr-x 30 root root 4096 Feb 17 18:05 /usr/lib/perl/5.8.4
drwxrwsr-x 9 root staff 4096 Mar 7 2002 /usr/local/lib/perl/5.6.1
drwxrwsr-x 21 root staff 4096 Dec 5 2003 /usr/local/lib/perl/5.8.0
drwxrwsr-x 4 root staff 4096 Oct 30 2003 /usr/local/lib/perl/5.8.1
drwxrwsr-x 11 root staff 4096 Mar 25 2004 /usr/local/lib/perl/5.8.2
drwxrwsr-x 12 root staff 4096 Jan 23 10:59 /usr/local/lib/perl/5.8.3
drwxrwsr-x 27 root staff 4096 Feb 17 18:08 /usr/local/lib/perl/5.8.4


On a box where Perl has been upgraded a few times there will be lots of old dirs with modules in...

posted by John  # 6:41:00 PM

Wednesday, February 16, 2005

Don't need patch... 

If you don't have patch installed on a machine it's OK...

You can still use diff to update files...

To update a file using diff & ed:


# (diff -e file1 file2 ; echo -e "w\nq" ) > diffs
# ed file1 < diffs


Bear in mind that it has no context, so it doesn't know where it is in a changed file, it just goes by absolute line number (which means you have to update the bottom of the file before you can update the start - if you're only taking across some of the changes then you need to start at the bottom of the file and work your way back, only updating a chunk at a time... also it's not reversable... patch can see if you're trying to run a patch in reverse... if you try running ed to apply a patch, but accidentally run it against the updated file... then you will really mess it up!

so... make a backup (easy for me to say!) and be CAREFUL!

posted by John  # 1:48:00 AM

Tuesday, February 15, 2005

cpio pass-through mode 

You have a web directory with 100000 files in it on a DVD.

You want to get a copy of all of the .htm files for editing...

find webdir/ -name "*.htm" | cpio -vdump /target/directory

(-a resets access times on source files, but no point using that on a DVD!)

The letters vdump can go in any order... more logically "padmuv", but "vdump" will be nice to remember! :o)

----

# tar cvf /target/directory/backup.tar $(find webdir/ -name "*.htm")
-su: /bin/tar: Argument list too long

# find webdir/ -name "*.htm" | wc -l
100810

posted by John  # 3:43:00 PM

Monday, February 07, 2005

Installing Debian from hard disk... 

http://d-i.pascal.at/
http://people.debian.org/~joeyh/d-i/images/daily/hd-media/

http://www.debian.org/devel/debian-installer/ports-status

http://www.debian.org/devel/debian-installer/


posted by John  # 1:17:00 AM

Sunday, February 06, 2005

If you want to reinstall everything... 

You could do this:


apt-get -u --reinstall --fix-missing install $(dpkg -S LC_MESSAGES | cut -d: -f1 | tr ', ' '\n' | sort -u)



posted by John  # 1:34:00 PM

Tip of the day... 

When you get Error 17 from grub it means it cannot find the partition you want it to boot...


GRUB Loading stage 1.5

GRUB loading, please wait....
Error 17


(ToDo: go back and check this, I got this message off the web, but it looks right)

The tip is...
be careful if you go using:


hide (hd0,0)


Because when you hide partitions it changes their partition type, and if you hide the one with the grub install in it (e.g. where your /boot is) then grub won't be able to access the menu.lst to know what to boot!

posted by John  # 11:56:00 AM

Saturday, February 05, 2005

Creating a bootable DOS partition from Linux 

(or "how to flash the BIOS on your Debian box without a floppy drive, or CD-ROM drive or Windows partition or USB boot or anything like that...")

This can be done!!! :o)

I have a PC with no floppy & no CD-ROM, it is running Sarge and has a second (empty) hard disk.

I needed to boot in DOS so I could flash the BIOS.

Add this to grub's config ( /boot/grub/menu.lst - I instinctively type vi etc because it's a config file, then realise it's in /boot/grub because it's for booting and needs to be in the boot partition (if that's partitioned)) :

title FreeDOS Image
root (hd1,0)
kernel /memdisk
initrd (hd1,0)/fdos1440.img

Download: Memdisk:

  • http://syslinux.zytor.com/memdisk.php


    I got the newest one out of the SysLinux 3.07 download

  • http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-3.07.tar.gz


    although if you apt-get install syslinux you get one too ( /usr/lib/syslinux/memdisk ) which you could use, but that's currently 2.11-0.1 or so.

    DOS floppy image:

  • http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/beta9sr1/fdos1440.img

    In Linux use fdisk (or cfdisk as I did) to create a small partition at the start of the empty disk (I did 8MB)


    Device Boot Start End Blocks Id System
    /dev/hdc1 * 1 1 8001 b W95 FAT32


    Use dosfstools mkfs.vfat to format the new partition:

    apt-get install dosfstools
    mkfs.vfat /dev/hdc1

    mount it:

    mkdir /mnt/hdc1
    mount /dev/hdc1 /mnt/hdc1

    copy memdisk and fdos1440.img and the flash program which you download from your hardware vendor into it:

    boot, choose FreeDOS Image, Choose 1:

    1->FreeDOS (speedup, 386+)

    Then choose 1:

    1) FreeDOS Beta9 ServiceRelease1 [2004-November-30]

    Then choose 2:

    2. FreeDOS Safe Mode (skip driver loading)

    ...and you should now find yourself at a nice little A:\>_ prompt :o)

    c:
    dir

    then there you are :o) You can now flash your BIOS because you are in native DOS.

    I'm wondering if you can use a loopback file within Linux as the root filesystem too, so you don't need a disk partition, now THAT would be scarey!!! :o)

    This guy needed a CD-ROM:

  • http://www.linuxsa.org.au/pipermail/linuxsa/2004-November/075117.html


    (wimp!)

  • Friday, February 04, 2005

    Power off on shutdown (with grub instead of LILO) 

    To power off on shutdown in Linux you need to do two things...

    Firstly the kernel needs to know to do it, and secondly the apm module needs to be loaded.

    You load the module by adding the line:

    apm

    to /etc/modules

    (or by doing "modprobe apm" for a one-off)

    I'm used to doing it with LILO, but with grub telling the kernel to use it is a matter of addding "apm=on" to the end of the "kernel" line in /boot/grub/menu.lst, after all the other stuff.


    posted by John  # 8:34:00 PM

    Thursday, February 03, 2005

    Upgrading from LILO to grub... 

    After all these years of staying away from grub (for various reasons ... mainly because the one time I'd been confronted with it there was a box which wouldn't boot in a computer room, there wasn't time to research, I didn't know anything about it, I didn't like the name, and I didn't know where to start...) I tried upgrading a box after installing a new Sarge box which installs grub by default so I hade something to compare with as a working example...

    Installing it was as simple as doing:

    As simple as running:


    grub-install /dev/hda


    (mine was: grub-install --no-floppy /dev/hda )

    (You can also use (hd0) instead of /dev/hda I believe.)

    Then making /boot/grub/menu.lst

    I have:

    default 0

    timeout 3

    color cyan/blue white/blue

    title Debian GNU/Linux, kernel 2.4.27-2-686
    root (hd0,0)
    kernel /boot/vmlinuz-2.4.27-2-686 root=/dev/hda1 ro
    initrd /boot/initrd.img-2.4.27-2-686

    savedefault
    boot

    title Debian GNU/Linux, kernel 2.4.27-2-686 (recovery mode)
    root (hd0,0)
    kernel /boot/vmlinuz-2.4.27-2-686 root=/dev/hda1 ro single
    initrd /boot/initrd.img-2.4.27-2-686
    savedefault
    boot

    You can do this automatically on Debian with:


    update-grub

    Wednesday, December 29, 2004

    Burning an ISO image under Linux 

    On my laptop with an internal CDROM:


    cdrecord -v -pad -tao -eject speed=8 dev=/dev/hdc sarge-i386-netinst.iso


    BTW:
    The image came from here: http://www.debian.org/devel/debian-installer/

    Or even just:


    cdrecord dev=/dev/cdrom sarge-i386-netinst.iso


    And this time I went for:

    http://cdimage.debian.org/pub/cdimage-testing/daily/i386/

    which fixed some problems I was having with the 2.6 kernel not wanting to mount the root image on my old 233MHz machine... (turning off things in the BIOS and managing to boot Knoppix under 2.6 let me know it was possible)

    Thursday, December 23, 2004

    Sea Pearl 

    It's funny how I know quite a lot about the history of the C Language, but don't write very much C, and know comparatively little about the history of Perl and write a LOT in it...!!!

    I would love to be able to rattle off C programs the way I churn things out in Perl, but somehow I don't think that C really lends itself to that kind of development.

    There certainly are times I wish I could write something in C to get better performance out of it, but when I try I often get muddled with where I am at and am not sure if I'm going about things the right way.

    One day Conrad, I'll do the C course that you recommended I do (*cower* 10 years ago now!!!) which I still haven't done! :o(

    I sometimes wonder if Casey is still using C as much as he did back then, and if so, what kinds of things he's using it for...

    Thursday, December 16, 2004

    Xsession error: open: Permission denied 


    Xsession: X session started for USER at Day Mon DD HH:MM:SS Zone YYYY
    open: Permission denied


    try:


    chmod 1777 /tmp




    Monday, September 20, 2004

    7-Zip 

    7-Zip

    rzip 

    rzip

    Unarchiving Spam 

    Unarchiving Spam

    Thursday, September 16, 2004

    Vim bits... 

    Today I learned that if I want to run the current line as a command and get
    the output, all I have to do is:

    <Esc>yy!!<Ctrl-R>"<BS><Enter>

    :-) happy now!?

    Careful if you've got a % in the line...

    Vim documentation: cmdline

    I needed \% for the %20 in the URL I was passing out.

    The <BackSpace> was because it put a ^M on the end of the line.
    I could have just gone 0y$ instead of yy

    I just KNOW I'm going to use this one a lot!!!

    So you know, the secret engrdient here is ^R which puts the content of the
    un-named register on the command line.

    the other (unrelated) thing that I looked up and clarified was the :a (short for *:append*) command (and discovered that there's also :i (short for *:insert*) which can be read about with :he :a and :he :i :o) I discovered :a quite by accident a long time ago and use it when I want to paste in text and don't want it to be auto-indented (if it has tabs or indents in it - e.g. when pasting code)

    Tuesday, September 07, 2004

    Island sizes... 

    Isle of Man is 53km (33 miles) long, 20km (13 miles) wide, land area 572 sq km (227 sq miles)

    Great Barrier Island is 40km (25 miles) long, 16km (10 miles) wide, land area 285 sq kilometres (110 sq miles)

    Chatham Island 61 km (38 miles) long, 40 km (25 miles) wide, 963 square km (372 sq miles)

    Stewart Island is 70 km long (45 miles) long, 40 km (25 miles) wide, land area 1,746 square km (674 sq miles)

    Jersey is 16km (10 miles) across, 8 km (5 miles) from north to south and has an area of 115 square km (44 sq miles)

    (Don't quote me on the Chathams length and width - they're from the 1911 encyclopedia which is full of inaccuracies.)

    Sunday, September 05, 2004

    USB Mouse with 2.6 Kernel 

    To get my USB mouse working with the 2.6 kernel (in Debian Sarge with 2.6.7)
    I had to add these modules to /etc/modules:

    usbhid
    uhci_hcd
    mousedev

    I didn't need usbcore because it loaded itself.

    I found that these also work for the 2.4.27 kernel, and I don't need the usbmouse module.

    Tuesday, August 31, 2004

    Windows Journal Viewer returns the alert 'The feature you are trying to use is...unavailable' when you start Acrobat (6.0 on Windows 2000 or XP) - Sup 

    Windows Journal Viewer returns the alert 'The feature you are trying to use is...unavailable' when you start Acrobat (6.0 on Windows 2000 or XP) - Support Knowledgebase

    Suckful little thing!!!

    Goes into a "I will beat on you until I am installed on your hard disk - at any cost!" loop...

    Only way to break out is with Task Manager...

    Microsoft Windows Journal Viewer 1.5

    "This accessory enables users who do not have a computer running Microsoft® Windows® XP Tablet PC Edition to view files that were created in Microsoft® Windows® Journal on a Tablet PC."

    Oh yeah, looks damn useful to ME... NOT!


    Saturday, August 28, 2004

    PS2 Mouse in X with 2.6 Kernel 

    When you upgrade to a 2.6 kernel from 2.4 you may find that X won't start.


    XFree86 Version 4.3.0.1 (Debian 4.3.0.dfsg.1-4 20040529113443 root@cyberhq.internal.cyberhqz.com)
    Release Date: 15 August 2003
    X Protocol Version 11, Revision 0, Release 6.6
    Build Operating System: Linux 2.6.6-rc3-bk9 i686 [ELF]
    Build Date: 29 May 2004
    Before reporting problems, check http://www.XFree86.Org/
    to make sure that you have the latest version.
    Module Loader present
    OS Kernel: Linux version 2.6.7-1-386 (dilinger@toaster.hq.voxel.net) (gcc version 3.3.4 (Debian 1:3.3.4-2)) #1 Thu Jul 8 05:08:04 EDT 2004
    Markers: (--) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
    (==) Log file: "/var/log/XFree86.0.log", Time: Sat Aug 28 14:10:06 2004
    (==) Using config file: "/etc/X11/XF86Config-4"
    (EE) xf86OpenSerial: Cannot open device /dev/psaux
    No such device.
    (EE) Implicit Core Pointer: cannot open input device
    (EE) PreInit failed for input device "Implicit Core Pointer"
    No core pointer

    Fatal server error:
    failed to initialize core devices

    When reporting a problem related to a server crash, please send
    the full server output, not just the last messages.
    This can be found in the log file "/var/log/XFree86.0.log".
    Please report problems to submit@bugs.debian.org.

    XIO: fatal IO error 104 (Connection reset by peer) on X server ":0.0"
    after 0 requests (0 known processed) with 0 events remaining.


    At the bottom of the /var/log/XFree86.0.log log file you will find:


    (**) Option "Protocol" "PS/2"
    (**) Implicit Core Pointer: Protocol: "PS/2"
    (**) Option "CorePointer"
    (**) Implicit Core Pointer: Core Pointer
    (**) Option "Device" "/dev/psaux"
    (EE) xf86OpenSerial: Cannot open device /dev/psaux
    No such device.
    (EE) Implicit Core Pointer: cannot open input device
    (EE) PreInit failed for input device "Implicit Core Pointer"
    (II) UnloadModule: "mouse"
    (II) Keyboard "Implicit Core Keyboard" handled by legacy driver
    (WW) No core pointer registered
    No core pointer

    Fatal server error:
    failed to initialize core devices

    When reporting a problem related to a server crash, please send
    the full server output, not just the last messages.
    This can be found in the log file "/var/log/XFree86.0.log".
    Please report problems to submit@bugs.debian.org.


    If you try catting the device:


    cat /dev/psaux
    cat: /dev/psaux: No such device


    Or:


    cat /dev/input/mouse0
    cat: /dev/input/mouse0: No such device


    If you load these two modules it will fix it:


    modprobe mousedev
    modprobe psmouse


    This can be made permanent by adding these two lines to the bottom of /etc/modules


    mousedev
    psmouse


    This page helped me: http://www.hup.hu/modules.php?name=Forums&file=viewtopic&t=2136
    It does have superstition and crap in it, like talking about the device being changed from /dev/psaux to /dev/input/mouse0 but it told me the right modules to load.


    Section "Pointer"
    Protocol "PS/2"
    Device "/dev/psaux"
    BaudRate 1200
    Emulate3Timeout 50
    Emulate3Buttons
    EndSection


    You can change this section if you like:


    # diff /etc/X11/XF86Config-4.old /etc/X11/XF86Config-4
    57c57
    < Device "/dev/psaux"
    ---
    > Device "/dev/input/mouse0"


    But I found I didn't need to - once I'd loaded the two modules both devices worked again.

    Listing packages with long names in Debian... 

    (export COLUMNS=256; dpkg --list) | awk '/kernel-/{print $2}'

    Monday, July 26, 2004

    Time for a general statement... 

    I'd like to refine this, but the gist of it is that more often than not if you're hunting for a tool on the net to do something in Windows... the quality of a freeware product is better than that of a shareware one... where possible I don't like to have any shareware on my machine at all.

    Perhaps part of the reason is that the motivation for freeware is to make the best possible product, while the motivation for shareware is to make money. If they can do it quick and dirty and pump it out and get dosh for it from the minimum investment - then that's the most suited to their needs.

    Friday, April 16, 2004

    I just clicked about something... 

    When in your mail logs it says:


    2004-04-16 07:41:05 recipients from [218.84.71.28] refused (failed to find host name from IP address)


    I had always thought that it meant that it had failed because it couldn't resolve the reverse name of the IP... and I thought "that's not RFC compliant - so why is it enforcing it?"

    Looking at the logs just now, I realised that it merely means that it failed (for some other reason), and when it tried to log the reverse name it couldn't resolve it... so it wrote "failed to find hostname..." where it would have normally logged the hostname... perhaps it should just put "could not resolve" or something which doesn't have the word "failed" in it...


    Friday, March 26, 2004

    It's frustrating sometimes that Debian (and much of Linux!) seems to be set up as a workstation operating system running X - apps like hnb come configured to launch X apps - when I want to use it tucked away on my server... tools like vim require gpm - when I'm hundreds of miles away from the mouse port, ImageMagick requires most of an X environment and epinfo requires digital camera stuff, when both of these tools are good to have for in-situ image work on my webserver...

    Thursday, March 25, 2004

    I've just tried out Flonix build41

    Hmmm - it has a fancy media centre app which feels like a full-screen DOS thing - good to hardwire as an interface for idiots - like in a public access terminal, but over-all I wasn't impressed with Flonix at ALL :o(

    My (negative) comments are:



    As a final whinge, the website isn't all that easy to get around - like how to find the download link...

    All in all, it looks like a rough hack to serve a purpose, good on him for putting it online for people to use, I hope it's that he's a newbie, not a rough oldbie... but at the end of the day it's not in the same league as Knoppix or DamnSmallLinux...


    Friday, March 05, 2004

    Turning the "My Documents" icon on and off... 

    I feel terrible about this, but I've been reduced to being a L00z3d0z3 luser again... new workplace with "thou shalt have thy productivity hobbled by using this inferior gunk on our hardware" - i.e. I have to run Win2K, can't use Linux... geh!

    I deleted the "My Documents" icon from the desktop and wanted to put it back a week later for some reason...

    I wrote this inf file:


    ;
    ; This turns on and off your "My Documents" folder on the desktop...
    ; Use to restore a deleted "My Documents" icon in Windows 2000
    ;

    [version]
    signature="$WINDOWS NT$"

    [DefaultInstall]
    DelReg=ClearOut
    AddReg=MyDocsOn
    ;AddReg=MyDocsOff

    [MyDocsOn]
    HKCU,%MD_SWITCH_PATH%,"Attributes",65537,74,01,40,f0

    [MyDocsOff]
    HKCU,%MD_SWITCH_PATH%,"Attributes",65537,74,01,50,f0

    [ClearOut]
    HKCU,%MD_SWITCH_PATH%,"Attributes"

    [Strings]
    MD_SWITCH_PATH="Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}\ShellFolder"


    It says "Installation Failed" when I run it, (not sure what it's missing), but it does actually work :o)

    Sunday, February 15, 2004

    I've been trying to buy a 256MB USB MP3 player (was that a lot of acronyms?) on eBay and I'm GUTTED I missed out on this one! (only by 29 minutes!)
    I have a goal to buy one for less than £48 !!! :o) (I still have to pay P&P on top of that = £7.50ish)

    Update:

    ARGH!

    Saturday, February 14, 2004

    The First Smiley :-)

    Believe it ?

    Actually, I've got more to add to that...

    Take two...

    The First Smiley :-)

    A CSS table which stays in the right place, but it's hardwired, which isn't very nice :o( http://www.gwyncole.com/blogfiles/gwync/MyCSSTable.htm

    Hmmm... I wish you could do with CSS what you can do with tables!!! somewhere, a LONG time ago (like 3+years) I read that the <TABLE> tag was invented for displaying data in a tabular form, not for page layout... well... I'm sorry to say, that while CSS was invented for formatting and page layout etc, it doesn't (yet) do as good a job as things like "I want a box at the bottom of my page, split into three equal boxes which will re-size with the page, and a box on top of that the width of the page... and I want it all to still work the same way in different browsers and I don't want to have to hard-wire specify the size in pixels - so that it will work the same on a smaller or larger screen too..." fixed dimensions for page layout suck - unless you are fixing something like an image along the side of the screen... i.e. It's probably ok to have an image in the top left corner, and something else immediately to the right of it (or below it) and want that to sit hard against it.

    It sucks having to have a gazillion nested tables on a page, all that extra overhead of source, and hard to keep track of while working in a text editor... but CSS isn't up to the job yet. Oh, and I LOVE finding pages on the web preaching that you shouldn't use tables for page layout... and then you look at the source of the page and they're... using tables for page layout!


    It would be wonderful to have a mobile device to code on!

    At the moment I just want something simple like an encryption tool... even rot13

    Can you write apps for Nokia 9110i & upload them? It's flakey enough as it is though.

    3735928559 = DEADBEEF in dec.

    is about the coolest of:

    grep -vi '[g-z]' /usr/share/dict/words

    Tuesday, February 03, 2004

    Wow! When you search for Great Barrier it's now 9 / 1,710,000 on Google...
    Such a long hard slog!!!

    Monday, February 02, 2004

    StumbleUpon looks really cool, but it's a bit scarey... what's in it for them ? are they spying on us ?

    Wednesday, January 14, 2004

    Hmmm... I'm quoted in China or should I say "taken out of context and *mis*-quoted in China!!!

    (also here)

    Which has been scraped from http://freshmeat.net/projects/fetchmail/?topic_id=28 at some stage...

    Which *used* to have the Cooler URL http://freshmeat.net/p/fetchmail/

    I hope all this work for SETI gets to be useful one day... seems like it ain't... how long should one keep going before giving up hope ?

    Class of Jul 19 2000

    There are times some people have expressed concerns over the security of running SETI, and
    Sometimes I wish I could really be contributing to something useful!!!

    (like do they really need supercomputers for DNA sequencing ? Is part of the job number crunching or pattern matching ? can't we help out too ?)

    Tuesday, January 13, 2004

    God I love Google!!!

    Thinking about writing a script which when given a list of files (or just two files?) goes through and looks inside each one and stores what the value of each byte is, then compares this with the next file... so that I could make it tell me what they have in common - to make writing a magic file entry easier... like a multi-file diff by byte not by line...

    I searched for: Google Search: xxd in perl (because xxd and od -c are my tools of choice for deconstructing files...) and I get this:

    Voltarian [simple] Perl Golf (xxd )

    :o)

    Now the hard bit is done... ;o)


    Monday, January 12, 2004

    Discussing Title Case in Perl...

    Sliding with Jim: Perl Tidbit for Title Case

    Thursday, December 25, 2003

    As far as I can figure we flip over out of the curent Unix time epoch at:

    %s = 2147483647 = Tue 19 Jan 2038 03:14:07
    %s = 2147483648 = Fri 13 Dec 1901 20:45:52


    If any of my current Linux boxes are still running then, are still on 32 bits dates and are still doing anything useful 34 years from now,
    I'll be DAMN proud of them and won't give a stuff that the time has gone loopy! ;o)

    We could always set them back to 1938 then ;o)

    I've got one thing to say...

    aotea:/var/mail/spam(61M@) [18691 msgs/6259 new]-(date-received)----------(end)-
    18667 N - Dec 26 Lupe Ivey ( 25) plea,se yo`ur `gi'rlfrei:nd' ckopw
    18668 N - Dec 13 Nichole Coffman ( 47) RE:Tramadol.l Valium.m Vicodin.n Xana
    18669 N - Apr 03 Goldie Dorsey ( 39) steely WANT TO BE A STUD LIKE THE OLD
    18670 N - Dec 25 Ulysses Hutton ( 103) Better Return, lower risk igo
    18671 N - Dec 25 Helen Wiseman ( 42) The Big Give:away is still on so get
    18672 N - Dec 26 Joaquin Brownin ( 18) watch the free 45min paris hilton vid
    18673 N - Dec 25 Daniel Burks ( 43) Alfred.buehrmann Zyprexa.a Vicodin.n
    18674 N - Dec 25 Percy Ramos ( 42) cnoatia attesbation ck xjki
    18675 N - Dec 25 Cornell Santiag ( 31) You will see real reesultz right away
    18676 N - Dec 26 Aurelia Schafer ( 34) You have an Overdue Balance
    18677 N - Dec 25 Bessie Kane ( 10) blast your boo, rock hard in 60 secon
    18678 N - Dec 18 Joyce Dotson ( 54) Soma.a Vicodin.n Valium.m Xanax.x lov
    18679 N - Dec 25 Myrtice Mellage ( 22) Fwd: Myrtice
    18680 N - Dec 25 Luella Sykes ( 46) centpnnial doldruns qq dmwb tb mdw
    18681 N - Dec 26 Spencer Fox ( 73) Italian-crafted Rolex - only $65 - $1
    18682 N - Dec 25 Ann L. Pierce ( 10) No Pills Or Capsules
    18683 N - Dec 25 Frances B. Hoyt ( 12) Please your lover better
    18684 N - Dec 25 Marshall Whitta ( 67) Teens deflowered for 50k spending cas
    18685 N - Mar 28 Cornelia ( 25) The summer of 2003...get ready now
    18686 N - Dec 25 Courtney Palino ( 22) Fwd: Courtney
    18687 N - Dec 25 Gideon ( 10) amag Get VIAGRA at $3 per dose. Best
    18688 N - Dec 25 Neddie ( 10) cho Energize your sex life right NOW.
    18689 N - Dec 25 Gallagher Franc ( 41) Re: XVZCEFYO, yesterday you were
    18690 N - Dec 13 Dolly Hurt ( 44) RE:Vioxx.x Valium.m Vicodin.n Xanax.x
    18691 N - Dec 25 Cynthia Bryson ( 21) Ikissed her ruby lips


    That's a LOT of spam!!! :o)
    (I haven't had a chance to clear the "spam" account where most of our spam gets directed since I left to go home to NZ on the 18th of July... and there's that many in there now!

    Sunday, December 21, 2003

    John's OpenVMS Webpage

    Friday, December 19, 2003

    Hmmm... this looks cool too Geeklog - The Ultimate Weblog System (*shrug* about the security issues)
    It's the software that Ralu is using on her site...

    Thursday, December 18, 2003

    And today, to brave of the cold I...

    Discovered how to change the colour scheme in playmp3list (YUCK! I hate the Ocean one that it is set to in Debian!!!)

    Found out how to define a custom icon for my homepage which overrides the default site icon...

    Found The Kewpie Doll Massacre in the GreyMatter Photo Gallery :o)

    Hmmm GreyMatter, you don't think I might have been searching for my own blog software do you ???

    Oh and I thought about joining the kiwi blogs too...


    Tuesday, December 16, 2003

    Here are some Javascript bits I came up with the other day...

    They won't work in Intranet Exploder, but they'll work with Ye Grande Ole Oprey, Nutscrape, Mozilly and Firebird... :o)



    Wednesday, December 10, 2003

    Laurence was talking about having worked on VXWorks

    Might read up on this a bit...

    Google: vxworks
    Google: vx works

    Which lead me to: The Official Abandonware Ring

    Tuesday, December 09, 2003

    How cool is that ? I just guessed 'cat -n' when I wanted to put line numbers on the output of grep... hehehe... 9 years using Unix almost daily and I'm still finding new tricks every day!!! I love Unix!!!

    BTW: I did:


    grep -v "^[^.]*#" example.txt | cat -n


    to find the number of non-commented lines in the file...


    ...ummm nl does the same...

    Hey, somewhere safe and out of the way to keep the geeky blog bits... :o)

    my normal (non-geeky) blog is at http://serf.blogspot.com/

    and most of my technical notes are in my wiki at http://wiki.a32.net/

    But this can be somewhere in between... :o)

    I think mostly I'll want to put things in the wiki still, because there's SO much stuff it needs to be easily grouped into relevant areas, and it's a godsend having the search engine on it too... (I just wish it was Google!)

    I got the idea for having a geek blog from David Graves' Geek Blog which I found today when looking for help on a strange Apache error message:

    [warn] (128)Network is unreachable: connect to listener

    which Laurence got at work today...

    Friday, November 28, 2003

    Am I a C/Perl/Korn zealot ?

    I don't use 'foreach' in Perl because it's too csh for me... I use 'for' instead...

    While I'm on that rant, there's no point using 'for each' either... each is a good tool, but after the for it's superfluous...

    Archives

    hacker emblem

    This page is powered by Blogger. Isn't yours?