#!/usr/bin/perl

#Sangoma USB Key Serial List Script

# Copyright     (c) 2012, Sangoma Technologies Inc.
#
#               This program is free software; you can redistribute it and/or
#               modify it under the terms of the GNU General Public License
#               as published by the Free Software Foundation; either version
#               2 of the License, or (at your option) any later version.
# ----------------------------------------------------------------------------



#currently based on the Vendor ID and Subvendor ID. Tested with USB keys used
#by Sangoma Marketing department.

#Add move vendor ID's here for different USB keys
my @vendor_id_list=("048d");

foreach my $vendor_id (@vendor_id_list) {
	my @serial_lines =`lsusb -d $vendor_id: -v | grep iSerial`;
	
	foreach my $serial_line (@serial_lines) {
		#format: "iSerial                 3 0000000016B17216"
		@tokens = split(/ /, $serial_line);
		$serial = @tokens[$#tokens];
		chomp($serial);
		print "$serial\n";
	}
}
