Simply Top Ad

Tuesday, March 9, 2010

Dell Service Tags to Express Service Codes in Perl

It seems that Dell Tech Support have replaced a layer of people with a layer of machines and as such whereas you could previously give your machine ID using the (alphanumeric) Service Tag to a person, you now need to give your machine ID to a machine, which means it needs to be the (numeric) Express Service Code.

This is no problem if you have the machine in question because the service tag sticker has both the (alphanumeric) Service Tag and the (numeric) Express Service Code.

However, if you had been noting only Service Tags from machines and storing those in your records, you might not have the (numeric) Express Service Code to hand and this may cause a problem.

It turns out that there is a relatively straightforward relationship between the Service Tag and the Express Service Code.

It seems that if you take the Service Tag and treat it as a base 36 number, then express that quantity as a base 10 number, and add hyphens in the right places, you get the Express Service Code.

The hyphens aren't crucial because you don't dial them, but if you want to match the existing codes exactly, it seems you need to add hyphens every three digits, but with the proviso that if we would otherwise end up with a single digit on its own, then we start with two digits instead of three.

Wanting to convert an existing file of service tags en masse, I came up with a little Perl program which would do it as a pipe filter:

perl -e 'while(<>){chomp; if(/^[0-9A-Z]{1,7}$/so){@a = split //; my %e; @e{"0".."9","A".."Z"} = (0..35); my $r = 0; while(@a){ $r = ($r * 36) + $e{shift @a}; }; @r = split //, $r; my @s; push @s, join "", splice @r,0,2 if ((@r % 3) == 1); push @s, join "", splice @r,0,3 while @r; $_ = join "-", @s; } print"$_\n";}'

No comments:

Post a Comment