Tuesday, October 2, 2012

VBoxManage list usbhost summary (VBoxHeadless)

When we use VBoxHeadless and want to add usb to virtual machine we have to use VBoxManage list usbhost to list all available usb and its UUID, but using command VBoxManage list usbhost it gives us lot of information and it will be saved time if we can summary to the information that we, so i have written a perl script to summary only to the UUID and Products

when using only the command VBoxManage list usbhost

root@tun-K42JB:/home/tun# VBoxManage list usbhost
Host USB Devices:

UUID:               2dbbee08-fa56-4e96-9675-5962c3d89737
VendorId:           0x04f2 (04F2)
ProductId:          0xb1e5 (B1E5)
Revision:           32.105 (32105)
Port:               1
USB version/speed:  2/2
Manufacturer:       Chicony Electronics Co., Ltd.
Product:            USB2.0 0.3M UVC WebCam
Address:            sysfs:/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2//device:/dev/vboxusb/001/003
Current State:      Busy

UUID:               55aba6b2-1c22-4695-a003-2bb891f16a0b
VendorId:           0x0b05 (0B05)
ProductId:          0x1788 (1788)
Revision:           4.73 (0473)
Port:               4
USB version/speed:  2/1
Manufacturer:       Broadcom Corp
Product:            BT-270
SerialNumber:       1C4BD60E7456
Address:            sysfs:/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5//device:/dev/vboxusb/001/004
Current State:      Busy

When using combine with my perl script

root@tun-K42JB:/home/tun# VBoxManage list usbhost | perl perl/pvirlistusb.pl



It summary the thing that i need to know.
This is my script look like:

root@tun-K42JB:/home/tun# cat perl/pvirlistusb.pl
open FIL,usbfilter;
$n = 1;
while (<>){
    if( $_ !~ /^\s+/) {
#        chomp;
        $_ =~ s/\s+/./g;
        $text[$n] .= $_."\n";

#    print $_;

$i =2;
while ($i < $n ){
    print "\n";
    while (<$text[$i]>){
    if ($_ =~ /UUID/){
        print $_."\n";
#    if($_ =~ /Manufacturer*/){
#        print $_."\n";
#    }
    if($_ =~ /Product:/){
        print $_."\n";
#        print $_;
#    print $text[$i].length;
#    print "\n";

#if ($text[1] =~ /UUID/){
#    print $_;
#print "$n \n";
#print "$text[2] \n";


1 comment: