A Slick USB Over IP Solution That I use Every Day

Let me show you a slick application I stumbled across about 6 months ago.  My HP all-in-one USB printer is certainly a handy device, but being bound to the thing via a USB cable was driving me nuts.  I wanted to have full control (which meant a print server wasn’t going to cut it) and I wanted that control from anywhere in my house over my wireless network.  Now, there are a number of products on the market that can do this.  As an example, AnywhereUSB from Digi is one such product which seems to have a good reputation and from what I’ve seen, it works well.  But, I was in one of my moods and I was bound and determined to find a free solution.  In my searches I found a few software products and tried the 30 day demos.  They all worked well but they weren’t free and they were all products for Windows.  And since my WindowsXP desktop is actually a VMware Workstation virtual machine running on top of Ubuntu Linux, what I really needed was a solution for Linux.

I knew that if I could find something for Linux I would kill two birds with one stone.  Because not only would I be able to connect USB devices to my Linux OS, but as an added benefit, my WindowsXP virtual machine would see the connected device just as if it were actually connected … no additional software needed for Windows!  Eventually I stumbled across USB Server (+ USB Client) for Linux Beta which is offered as a freeware product from IncentivesPro (http://www.incentivespro.com).  After playing with the product a bit and creating a few custom scripts to further automate the connecting and disconnecting of USB devices, I found the solution I was looking for!  And I can tell you, I use the product on a daily basis.  Here’s a quick look at my setup.

1) I have an HP all-in-one USB printer connected to a Linux server running USB Server for Linux.

2) On my laptop, running Ubuntu 8.04 I have the USB Client for Linux installed.

3) To automate the process of connecting to the server and attaching the USB devices, I created a Bash script called connect_usb.  Simply running this script produces the following output …

asweemer@cowbuntu:~$ connect_usb
Restarting USB Server on sweemserv … Success!
Restarting local USB Server … Success!
Connecting to USB Server on sweemserv … Success!
Looking for USB Devices on sweemserv … Success!
Found the following USB Devices on sweemserv:

1: USB Server on sweemserv:32032 status: [connected]
‘–> 5: USB Device:   Officejet 5600 series  HP  – Composite USB Device
busid: 1-1       hwid: 03f0-4f11
speed: [full]    status: [device is connected]

Connecting to the USB Devices on sweemsrv … Success!
asweemer@cowbuntu:~$

After I see this, I have full control of the device just as if I had the USB cable plugged directly into my laptop.

4)  I already mentioned that I run my VMware corporate XP desktop as a Workstation 6.5 instance.  The USB Client presents the USB devices as local, so I connect to them in Workstation as if they were directly connected devices.  Check out the following screenshot …

See the last line “Hewlett-Packard Officejet 5600 series”?  That’s the printer.  And believe me, it’s not local like the other devices in the list, but VMware Workstation doesn’t know the difference.  And when I connect the device to the virtual machine, WindowsXP doesn’t know the difference either.

6) That’s it!  Works like a charm everytime 🙂

If you’d like a copy of the Bash script, let me know and I’ll update the post.  Also, I’d be interested in any other unique ways to handle USB Redirection, so please comment if you have a solution.

5 comments Add yours
  1. I've been so busy the past few weeks, I haven't had much of a chance to update the blog. Sorry for the delay. The script is below. I'm not a bash expert, so I'm sure there's a better way to do it, but this seems to work well for me.

    Here are the quick and dirty instructions

    1) [optional] Add your username to the /etc/sudoers file with the NOPASSWD: ALL option set for your username
    2) Make sure your usb server is running an SSH server and that you can connect to it as root. [optional] It's also helpful if you have your SSH keys properly configured so the SSH server doesn't prompt you for a password.
    3) Copy the text below and save it in your ~/bin directory as connect_usb (or whatever filename you'd like). Don't forget to make the file executable (chmod 755 ~/bin/connect_usb)
    4) Once you've configured your IncentivesPro software properly, run sudo ~/bin/connect_usb.

    Let me know if you have any questions.

    Thanks,
    Aaron

    #!/bin/bash

    USBSRV=”1.2.3.4″
    CLIENT=`which usbclnt`

    success () { echo “Success!”; sleep 2; }
    fail () { echo “Failed!”; exit; }

    echo -n “Restarting USB Server on $USBSRV …”
    if `ssh $USBSRV '/etc/init.d/rc.usbsrvd restart | grep “usbsrvd” &>/dev/null'`
    then success
    else fail
    fi

    echo -n “Restarting USB Server on localhost … “
    if `/etc/init.d/rc.usbsrvd restart | grep “usbsrvd” &>/dev/null`
    then success
    else fail
    fi

    echo -n “Connecting to USB Server on $USBSRV … “
    if `$CLIENT -a USBSRV:32032 | grep “Operation is not completed!” &>/dev/null`
    then fail
    else success
    fi

    echo -n “Looking for USB Devices on $USBSRV …”
    if `$CLIENT -l | grep “[device is available for connection]” &>/dev/null`
    then success
    else fail
    fi

    echo “Found the following USB Devices on $USBSRV …”
    $CLIENT -l | awk '$0 == “” {sw=0} $7 == “[connected]” {sw=1} sw == 1 {print $0}'

    a=`$CLIENT -l | awk '$7 == “[connected]” {print substr($0,1,1)}'`
    for b in `$CLIENT -l | awk '$1 ~ /–>/ {print substr($0,8,1)}'`
    do
    if `usbclnt -c $a-$b | grep “Operation is not completed” &>/dev/null`
    then echo “Could not connect to device $b on $USBSRV”
    else echo “Connected to device $b on $USBSRV”
    fi
    done

  2. I've been so busy the past few weeks, I haven't had much of a chance to update the blog. Sorry for the delay. The script is below. I'm not a bash expert, so I'm sure there's a better way to do it, but this seems to work well for me.

    Here are the quick and dirty instructions

    1) [optional] Add your username to the /etc/sudoers file with the NOPASSWD: ALL option set for your username
    2) Make sure your usb server is running an SSH server and that you can connect to it as root. [optional] It's also helpful if you have your SSH keys properly configured so the SSH server doesn't prompt you for a password.
    3) Copy the text below and save it in your ~/bin directory as connect_usb (or whatever filename you'd like). Don't forget to make the file executable (chmod 755 ~/bin/connect_usb)
    4) Change the IP address of USBSRV to the IP address of your server.
    5) Once you've configured your IncentivesPro software properly, run sudo ~/bin/connect_usb.

    Let me know if you have any questions.

    Thanks,
    Aaron

    #!/bin/bash

    USBSRV=”1.2.3.4″
    CLIENT=`which usbclnt`

    success () { echo “Success!”; sleep 2; }
    fail () { echo “Failed!”; exit; }

    echo -n “Restarting USB Server on $USBSRV …”
    if `ssh $USBSRV '/etc/init.d/rc.usbsrvd restart | grep “usbsrvd” &>/dev/null'`
    then success
    else fail
    fi

    echo -n “Restarting USB Server on localhost … “
    if `/etc/init.d/rc.usbsrvd restart | grep “usbsrvd” &>/dev/null`
    then success
    else fail
    fi

    echo -n “Connecting to USB Server on $USBSRV … “
    if `$CLIENT -a USBSRV:32032 | grep “Operation is not completed!” &>/dev/null`
    then fail
    else success
    fi

    echo -n “Looking for USB Devices on $USBSRV …”
    if `$CLIENT -l | grep “[device is available for connection]” &>/dev/null`
    then success
    else fail
    fi

    echo “Found the following USB Devices on $USBSRV …”
    $CLIENT -l | awk '$0 == “” {sw=0} $7 == “[connected]” {sw=1} sw == 1 {print $0}'

    a=`$CLIENT -l | awk '$7 == “[connected]” {print substr($0,1,1)}'`
    for b in `$CLIENT -l | awk '$1 ~ /–>/ {print substr($0,8,1)}'`
    do
    if `usbclnt -c $a-$b | grep “Operation is not completed” &>/dev/null`
    then echo “Could not connect to device $b on $USBSRV”
    else echo “Connected to device $b on $USBSRV”
    fi
    done

  3. i really need this type info who solved my problem because i am really much more used the USB device and i never live that because it's very helpful to me. please find the solution. i am waiting your next info.

Leave a Reply

Your email address will not be published. Required fields are marked *