Tag Archives: MCslp Coalface

Making a single extractor

One of my new articles is on smplifying your command line (read more about System Administrators Toolkit: Standardizing your UNIX command-line tools, making your life easier as you move between different environments. The same principles can be applied just to make your life easier. Here’s a function I’ve had in my bash init script for years that gets round the issue of extracting a compressed archive file of various types, even if your tar isn’t aware of the compression type:

function uz ()
{
    file=$1
    case $file in
        (*gz)  gunzip -c $file|tar xf -;;
        (*bz2) bunzip2 -c $file|tar xf -;;
        (*Z) tar zxf $file;;
        (*zip) unzip $file;;
    esac
}

Now I can extract any file with:

$ uz file{gz|bz2|zip|Z)

And not worry that my Solaris tar isn’t bzip2 aware even though it is Gzip aware.

Photo blogging with the K800i

As planned, I got a K800i earlier this week, and it’s taken me the best part of the week to try and sort out all of the different elements. I already did a quick post on Convergence in mobile phones with the SE K800i at ComputerWorld, but I thought it would be worth looking at some of the other elements.

With Mac OS X, it doesn’t take much work to get everything set up, but it has taken me a while to sort out and organize some of the more fun elements. Getting the phone syncing with my address book was achieved using the plugin available from feisar.com.

To populate the audio so that I can use it for what I used to employ the iPod shuffle for, I used iTunes to create 128Kbps AAC files; when you connect the camera through the supplied USB cable, the Memory Stick Micro card appears on the desktop just like a USB thumb drive - so you can copy the files (including the folders) over so you can play them. Playback through the headphones is great. Through the built-in speaker, it’s good enough to use in a small room for some ambient noise. My only problem now is remembering to pick up the headphones each time I leave.

I’ve also set up the email for the phone so that I can pick up emergency messages on the phone when away from the office. The phone has it’s own email address (technically it has two, my own and one provided by the mobile phone operator (O2)), and I’ve set up some rules within sieve to forward specific types of message to the phone.

As I hoped (and to be honest, expected) the quality of the camera is superb, and I love the way you can use this to blog directly just by pressing a button (you can see the results and quality at Martin MC Brown’s Mobile Blog. OK, so I might be late to the whole mobile blogging thing, but honestly, it works so great that my mother could be doing this.

The camera itself works just like a Sony camera - you get the same controls, zoom, built in flash, auto-focus and you can set a full range of options, like metering mode, white balance and selected special photo subjects with corresponding optimized settings. The results are obviously less expansive than those on my Sony P200, but definitely a good range given that we are talking about the camera built into a mobile phone.

Having said for years I was never going to get a mobile phone with a built in camera, I can now imagine a situation where the walks to the post office or those ever-so-rare cat shots suddenly become possible (nay, necessary) when I can publish them straight to the blog from the phone.

Expect more photos and experience notes as I get to use the camera more. Afterall, I’m still yet to actually make or receive a phone call!

Picking a phone based on its case

I’m in the market for a new phone, but I’m sadly addicted to Vaja leather cases, and they don’t have a case available for all phones. This is strangely limiting my choice - if I can’t find a Vaja case, I’m less inclined to buy the phone.

My current mobile phone is a Sony Ericsson T68i, which is getting a little bit long in the tooth, but still actually does everything I want. It’s encased in a lovely yellow Vaja tailor made case. It matches the one of the same colour that surrounds my iPod, and conveniently also matches (some) of my watches.

Shortly though I’m going to have to bite the bullet and buy a phone that I hope Vaja will suport in the future. At the moment, I’m thinking the

Another day, another thunderstorm, another Internet disconnect

In the height of the British summer, we are having some cold weather and, for the last few days, heavy thunderstorms.

I’m no fan of the sun, but the thunderstorms cause connectivity problems for me, and that disconnects me from the Internet for a while. Sometimes, I don’t notice for a while, other times it will hit me right in the middle of a download, and then I tend to notice immediately.

The problem is that the disconnect can be for long enough that I’m completely out of contact. Yesterday the storms were so bad that I was unable to call on the mobile phone because the normally strong signal wsa unavailable.

I can cope with intemittent connectivity, unless it affects my work, and it’s then that you realize just how reliant you are on being connected. Somehow, I need to put a backup plan in place.

Copying multiple files with scp

I keep my .bash init scripts on one machine and copy them over to each machine on which I have a login. There’s various bits of logic in there to ensure that the right PATH and other values are set according to the host and/or platform.

I then have a simple line that updates the .ocal .bash scripts from the main box that holds the main copies, so that I can just run:

update-bash

To update everything. I use scp and, depending on the system, use a preset key or require a password.

For copying multiple files there are many solutions; I could just use .bash*, but I’d also get the history and backup files. The typical advice is separate entries:

scp mc@narcissus:.bashrc mc@narcissus:.bash_aliases

This is less than optimal for a number of reasons - the first is that each location is treated individually, and that requires multiple connections and multiple password requirements. You can, though, use normal shell like expansion, just make sure you use quotes to ensure that it isn’t parsed and expanded by the local shell instead of the remote one:

alias update-bash='scp mc@narcissus:".bash{rc,_path,_aliases,_vars}" ~;. ~/.bashrc'

Getting Solaris 10 working in Parallels

I’ve just been sent the latest version of Solaris 6/06 release) and wanted to get it working in a Parallels virtual machine.

Not everything is plain sailing, but with a combination of past experience and a few quick configuration changes you can get it working fine.

Basic installation

The key to getting the basic installation working fine is to ensure you choose and set the correct options when configuring the disk device. The Solaris Installer will see the virtual disk, but for some reason wont automatically perform the fdisk partition for you. Once you get to the option that shows the disk drives and default partition, make sure you go through the FDISK configuration and create a single partition. This will give Solaris the block device it needs to then create it’s own partition map.

Networking

Once booted up, you’ll need to get the networking driver that comes with the Parallels boot disk installed. Attach the vmtools.iso disk (on Mac OS X this is located in /Library/Parallels/Tools); it should automount in Solaris. Navigate through to the network/Solaris directory and run the network.sh script to install the driver and configure the IP address, netmask and gateway. You’ll need to reboot.

Once rebooted, copy /etc/nsswitch.dns to /etc/nsswitch.conf to enable DNS searches for hosts, and then edit /etc/resolv.conf with your domain name (optional) and nameserver information. For example, mine reads:

domain mcslp.pri
nameserver 192.168.0.22
nameserver 192.168.0.24

X11 configuration

The default X11 configuration will often work fine for the display and keyboard, but the mouse fails to be configured. You need to configure the mouse to use the /dev/kdmouse device and operate as a PS/2, not USB, mouse.

You can do this by hand by editing the /etc/X11/.xorg.conf file, or you can create your own, or you can download this file and copy it into /etc/X11/xorg.conf.

If you want to go through the process yourself, first run kdmconfig and set it to use X.org.

Then run /usr/X11/bin/xorgconfig - you’ll need to go through each step (which involves setting up the mouse, keyboard and display). Select the PS/2 mouse option and give the driver name. Choose an appropriate keyboard layout (I’m using the 102-key international layout and haven’t had any issues yet.

For the display driver, configure a multisync monitor (using huge manual horizontal and vertical refresh values) or using the largest of the options provided, and select VESA as the display adaptor type, setting an appropriate amount of video RAM etc. to get the display depth and size you want.

All set!

That should be everything - you can see a sample of Solaris 10 running in Parallels below.

.

Stepped execution with cron and at

I had a query from a reader today as a follow up to my System Administrators Toolkit: Time and event management article at developerWorks:

How do I execute a script at a specific interval, for example 28 days, rather than on a specific day or date?

It is the one limitation of cron that it doesn’t support such an interval, although there are some systems (including many Linux installations) that provide an alternative method. There are some solutions to the problem that will work on any platform that uses the cron/at system.

One way is to run the script every 7 days, and have it record how many times it’s been called in a file.

All you have to do is, in the script, load the current count, work out if this is the fourth time, and run the script accordingly.

For example:

count=`cat counter`
count=`expr $count + 1`

if [ $count -eq 4 ]
then
echo 0 >counter
echo 4th time called, going for it
# Do everything else
else
echo $count >counter
fi

I suggest you put the counter file into a usable location, but you get the idea.

The other alternative is to use at, rather than cron, and then add a line in the script to execute the script again in 28 days time. For example, using this line at the end of your script:

at 9pm + 28 days <myscript .sh

Because you are specifying the same time, but a different day, this will execute at the same time every 28 days.

If your script takes a long time to process and you run it, for example, at 23:59, put the ‘at’ line at the start of the script, rather than the end, so that the request gets registered on the same day.