Posts Tagged ‘Unix’

Hilbert Curve TNG - Unix port

Sunday, April 20th, 2008

The Hilbert Curve Rework project is progressing well with version 2.05 having been released, by Nick earlier this week. Ive now taken the opportunity to port the current Windows code across to unix and particularly FreeBSD. Around 10 lines worth of changes later the app built and ran on my FreeBSD 7.0 system. For once the mantra of the C/C++ work actually proved try - write once, run anywhere. I really wish Java was that simple.

A couple of issues still need to be addressed:

  • Rework the source to we can maintain a single source three for Windows and Unix targets- this is mostly slog rather than thinking work.
  • There is a bug in that some images are coming out a little wrong, but I think this may have to do with line termination issues the good old \r\n vs. \n issue again.
  • Write some decent docs!

With a bit of luck Nick should be returning to Grahamstown for a month or so thanks to some funding from the Center of Excellence in the department. Working on the Hilbert project will be one of his main priorities.

Remote FreeBSD install - Depenguinator TNG

Saturday, April 19th, 2008

Daniel Gerzo, has recently published an article as part of the FreeBSD documentation project on how to install FreeBSD on a remote system, when one doesn’t have the luxury of a IP KVM or other remote console. Unfortunately most hosting providers seem to think Linux in its gazillions of flavors (really who would want to run Gentoo?) is the preferable option to windows.

The basic process is about creating a magic memory File System 9MFS) based mini FreeBSD install one can then ddover the base MBR on the system This gets you jsut enough of a Real OS to carry on with the rest of your install.

What this means for me is the possibility of doing some nice rmeote upgrade, or more acuratlye nuke and paves on some remorely hosted equipment. The big cath of course is your remote systems should have sufficient bandwidth (, or at least a local copy of the ISO or CD handy and mounted. Exploring other hosting providers may also now be feasible, now that I can run my favorite server OS without having to try persuade remotes upport to just put a BSD CD in and let me pay for a KVM access window :-)

Sorting IPv4 Addresses with GNU Sort

Tuesday, April 8th, 2008

While processing some rather large lists of addresses as part of a side project, I needed to be able to sort them in a numerical order within a shell script. I had a file with lines like:

  • 69.90.132.19
  • 69.90.132.22
  • 66.152.91.84
  • 208.122.204.181
  • 69.90.132.22
  • 69.90.132.31
  • 216.131.106.249
  • 216.131.84.26
  • 67.55.105.252
  • 208.64.44.102

Standard sort using sort –n only sorts on the first octet, and although it’s a improvement on alphabetic sorting its not ideal. The solution comes in specifying a pile of switches to sort:

sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4

This gets it sorted in Numerical order, by octet, using a period (dot) as a separator between octets. Combining this with a –u flag gives one a nicely sorted, unique list of IP addresses. This could probably be extended to IPv6 without too much hastle.