Ping with timestamp

For some reason standard ICMP utilities (e.g. ‘ping’) do not support formatting the output in a way that makes it easy to do further processing. The following Perl script should work on any Mac or Linux system. It wraps the standard ping command and formats the output as comma separated values that can be directly imported into for instance Microsoft Excel.


#!/usr/bin/perl

use strict;
$| = 1;

my $host = $ARGV[0];
open PING, "ping $host |" or die "Error :$!";

while() {
 if($_ =~ m/.*seq=(\d+).*time=([\.0-9]*).*/) {
  my($s,$m,$h,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
  my $dt = sprintf("%4d-%02d-%02d,%02d:%02d:%02d", $year+1900, $mon+1, $mday, $h, $m, $s);
  print "$dt,$1,$2\n"
 }
}

Download script.

Version control a Rails application with SVN

I have been looking at Git for version control but so far I am using SVN. Whenever I set up a new Rails application and add it to my version control system I do the following to ignore files that should not be version controlled.

  1. Copy the entire project to a folder within my SVN working folder hierarchy
  2. Remove all superfluous files:

  3. rm tmp/*/*
    rm log/*
    rm `find . -name '.DS_Store'`
    rm `find . -name '*.sqlite3'`
    rake db:migrate VERSION=0

  4. Add all files (svn add *)
  5. Set properties on the Rails folders to ignore certain files

  6. svn propset svn:ignore "*.log" log/
    svn propset svn:ignore "*" tmp/sessions tmp/cache tmp/sockets
    svn propset svn:ignore "*.rb\n*.sqlite3" db
    svn propset svn:ignore ".DS_Store" .

  7. Make an initial commit (svn ci -m “Initial import”)

Upgrade Ubuntu 6.10 (Edgy) after End-of-life

As of April 25th Ubuntu 6.10 (a.k.a Edgy Eft) is no longer supported. Any attempt to update the software from the standard repositories will therefore result in broken links.

To be able to upgrade the system the first task is to update the system to 7.04 (Feisty Fawn). This is done by replacing all instances of ‘edgy’ in the file /etc/apt/sources.list with ‘feisty’. This can be done manually using a text editor of choice or by running the following command.


sudo sed -e 's/\sedgy/ feisty/g' -i /etc/apt/sources.list

After that it should be possible to run ‘apt-get update’ followed by ‘apt-get dist-upgrade’ to upgrade the system to 7.04. Once there it is possible to use the standard method of upgrading to newer releases:


sudo apt-get install update-manager-core
sudo do-release-upgrade

During the upgrade process you will have to answer questions on what to do with files which have been edited. Run the above multiple times to upgrade to the newest version. It is possible to check the current version by running ‘cat /etc/issue’.