weblog d’un abbe

20080619

Filed under: Fun — abbe @ 2244

Please refer to the following *interesting* traceroute output from a
box in the VSNL network:

edmond@monte-cristo:~$ traceroute -I  msdn.microsoft.com
traceroute to msdn.microsoft.akadns.net (65.55.11.235), 30 hops max,
52 byte packets
 1  210.211.168.1.bb-static.vsnl.net.in (210.211.168.1)  26.749 ms
27.256 ms  27.091 ms
 2  delhi-203.200.108-213.vsnl.net.in (203.200.108.213)  26.836 ms
27.022 ms  26.588 ms
 3  59.163.16.138.static.vsnl.net.in (59.163.16.138)  294.918 ms
294.162 ms  295.428 ms
 4  219.64.231.5.mpls-vpn-sj.static.vsnl.net.in (219.64.231.5)
299.259 ms  299.098 ms  298.917 ms
 5  ge-6-3-0-46.pao-64cb-1b.ntwk.msn.net (207.46.46.67)  298.534 ms
299.173 ms  297.798 ms
 6  ge-1-2-0-0.tuk-64cb-1b.ntwk.msn.net (207.46.33.222)  312.887 ms
313.286 ms  313.417 ms
 7  ge-3-0-0-0.co1-64c-1b.ntwk.msn.net (207.46.34.41)  316.248 ms
317.286 ms  316.995 ms
 8  ge-0-0-0-0.co1-64c-1a.ntwk.msn.net (207.46.34.189)  321.016 ms
320.803 ms  320.532 ms
 9  10.22.8.62 (10.22.8.62)  321.021 ms  319.924 ms  319.659 ms
10  * * *
11  * * *
12  * * *
13  * * *
14  * * *

And following is the output of traceroute from a box in Airtel Broadband network.

abbe [~] chateau% sudo traceroute -I msdn.microsoft.com
Password:
traceroute to msdn.microsoft.akadns.net (65.55.11.235), 64 hops max, 72 byte packets
 1  * * *
 2  ABTS-NCR-Static-246.220.160.122.airtelbroadband.in (122.160.220.246)  33.458 ms  29.046 ms  30.290 ms
 3  rasBTNLDel-static-174.215.56.202.mantraonline.com (202.56.215.174)  33.563 ms  31.811 ms  30.377 ms
 4  125.19.22.145 (125.19.22.145)  29.517 ms  28.377 ms  30.774 ms
 5  125.21.167.25 (125.21.167.25)  75.891 ms  75.737 ms  75.602 ms
 6  sl-gw39-nyc-10-1.sprintlink.net (160.81.228.73)  294.580 ms  301.473 ms  306.050 ms
 7  sl-bb21-nyc-3-0-0.sprintlink.net (144.232.13.57)  297.558 ms  297.729 ms  299.510 ms
 8  sl-bb22-nyc-14-0.sprintlink.net (144.232.7.102)  304.510 ms  314.244 ms  305.923 ms
 9  sl-bb21-chi-3-0-0.sprintlink.net (144.232.20.102)  332.567 ms  331.458 ms  331.284 ms
10  sl-bb25-chi-13-0.sprintlink.net (144.232.26.90)  328.455 ms  328.153 ms  360.344 ms
11  sl-bb20-sea-1-0.sprintlink.net (144.232.20.85)  370.266 ms  367.872 ms  369.547 ms
12  sl-gw20-sea-0-0-0.sprintlink.net (144.232.6.8)  375.711 ms  406.419 ms  378.141 ms
13  sl-microsoft-23-0.sprintlink.net (144.224.113.146)  384.781 ms  383.371 ms  387.322 ms
14  207.46.41.125 (207.46.41.125)  401.802 ms  402.980 ms  415.847 ms
15  ge-3-0-0-0.co1-64c-1b.ntwk.msn.net (207.46.34.41)  388.315 ms  549.512 ms *
16  ge-0-0-0-0.co1-64c-1a.ntwk.msn.net (207.46.34.189)  390.412 ms  416.519 ms  386.261 ms
17  * * *
18  * * *
19  * * *
20  * * *

VSNL, which has got peerings with MSN, whereas Airtel Broadband connects via Sprint.

Good fences make good neighbors (at least valid in case of Internet)

Want to script CUPS print queue management

Filed under: Hacking — Tags: , , , — abbe @ 0101

Following is the python script I hacked, with my limited python skills, to script addition/deletion of cups print queues, when I’d to install same set of printers on 15-20 GNU/Linux boxen:

#!/usr/bin/env python
# manage-printer.py: manage cups queues using command line
# author: Ashish Shukla <gmail.com!wahjava>
# license: gnu gpl license v2 or v3

# requires hplip
import cupsext
import sys

def list_printers():
	"List printers"
	printers = cupsext.getPrinters()
	for printer in printers:
		print "%s at %s" % (printer.name, printer.device_uri)

def add_printer(name, uri, location, ppd, info):
	"Adds a new printer"
	(status, status_str) = cupsext.addPrinter(name, uri, location, ppd, '', info)

def del_printer(name):
	"Delete a printer"
	return cupsext.delPrinter(name)

def printer_exists(printer_uri):
	"Checks if printer exists"
	printers = cupsext.getPrinters()
	for printer in printers:
		if printer.device_uri == printer_uri:
			return printer.name
	return None

def main():
	# list all printers
	if sys.argv[1] == "-l":
		list_printers()
	# add a new printer
	elif sys.argv[1] == "-a":
		printer_name = sys.argv[2]
		printer_uri = sys.argv[3]
		printer_ppd = sys.argv[4]
		printer_location = sys.argv[5]
		printer_info = ''
		add_printer(printer_name, printer_uri, printer_location, printer_ppd, printer_info)
	# check if a queue to a specific URI exists
	elif sys.argv[1] == "-g":
		printer_uri = sys.argv[2]
		printer_name = printer_exists(printer_uri)
		if printer_name == None:
			sys.exit(1)
		else:
			print printer_name
			sys.exit(0)
	# delete printer
	elif sys.argv[1] == '-d':
		printer_name = sys.argv[2]
		if del_printer(printer_name):
			sys.exit(0)
		else:
			sys.exit(1)

###
# usage: ${0} -l 
#             -a [queue-name] [printer-device-uri] [path-to-ppd-file] [printer-location-field] [printer-info] 
#             -g [printer-uri] |-d [queue-name])
#             -d [queue-name]
###

if __name__ == "__main__":
	main()

# vim:ts=4:sw=4

The script is poorly documented, maybe someone like to extend it. BtW, this script requires cupsext from hplip package. Happy hacking….:)

P.S. Lazy hackers, and bots can download the script from http://wahjava.googlepages.com/manage-printer.py.

20080615

irssi notifications

Filed under: Hacking — Tags: , , , , — abbe @ 0049

notify-irssi.pl
Following is the code of irssi plugin, which I hacked. It displays popup messages (using notification-daemon) for any IMs you received:

# irssi-notify.pl
use Irssi;
use Net::DBus;
 
$::VERSION='0.0.1';
%::IRSSI = (
    authors => 'Ashish Shukla',
    contact => 'gmail.com!wahjava',
    name => 'irssi-notify',
    description => 'Displays a pop-up message for message received',
    url => 'https://wahjava.wordpress.com/',
    license => 'GNU General Public License',
    changed => '$Date$'
    );
 
my $APPNAME = 'irssi';
 
my $bus = Net::DBus->session;
my $notifications = $bus->get_service('org.freedesktop.Notifications');
my $object = $notifications->get_object('/org/freedesktop/Notifications',
					'org.freedesktop.Notifications');
 
my $notify_nick = 'abbe';
 
# $object->Notify('appname', 0, 'info', 'Title', 'Message', [], { }, 3000);
 
sub pub_msg {
    my ($server,$msg,$nick,$address,$target) = @_;
 
    if ($msg =~ $notify_nick)
    {
	$object->Notify("${APPNAME}:${server}",
			0,
			'info',
			"Public Message in $target",
			"$nick: $msg",
			[], { }, 3000);
    }
}
 
sub priv_msg {
    my ($server,$msg,$nick,$address) = @_;
    $object->Notify("${APPNAME}:${server}",
		    0,
		    'info',
		    'Private Message',
		    "$nick: $msg",
		    [], { }, 3000);
}
 
sub cmd_notifyon {
    my $nick = shift;
 
    if(!$nick)
    {
	Irssi::print("Current notification nick is $notify_nick .");
    }
    else
    {
	$notify_nick = $nick;
    }
}
 
Irssi::signal_add_last('message public', \&pub_msg);
Irssi::signal_add_last('message private', \&priv_msg);
Irssi::command_bind('notify-on', \&cmd_notifyon);

To use it: copy, paste it into a file, say irssi-notify.pl in your $HOME. And then start irssi , and load plugin with command /script load ~/irssi-notify.pl and after that use /notify-on command to register your nick with this plugin, so it’ll popup messages with you nick mentioned. e.g. to register mikeab for notifications, I’ll do /notify-on mikeab. You’ll also need Net::DBus perl module. Happy irssi -ng…:)

P.S. BtW, there is another similar plugin also, which doesn’t require DBus, and it is available from http://codesnippets.joyent.com/posts/show/1394.

UPDATE: You can also download irssi-notify.pl.

20080609

Google Gadgets on FreeBSD

Filed under: Hacking — Tags: , , , — abbe @ 0540

Google Gadgets on FreeBSD Google Gadgets on FreeBSD (compiz enabled)
For those who want to install Google Gadgets on their FreeBSD box (running GNOME), I’ve hacked a port and submitted as ports/124403. Waiting for it to comitted soon…:)

UPDATE: Port is now committed and available at deskutils/google-gadgets.

20080605

No more bashing

Filed under: Personal — abbe @ 1413

This post is not about me stopping bashing against any closed source companies. But, I’m switching to zsh from bash. There is no problem with bash. And bash still rocks.

20080603

GNOME Online Desktop on FreeBSD

Filed under: Yippee!! — Tags: , , , — abbe @ 2241

I have ported GNOME Online Desktop to FreeBSD. which is now available in ports tree at net/online-desktop. Enjoy…;)

Create a free website or blog at WordPress.com.