Results 1 to 6 of 6

Thread: Bash Script, lsusb

Threaded View

  1. #1
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,125
    Distro
    Ubuntu 10.04 Lucid Lynx

    Bash Script, lsusb

    Hi all I have a usb device that I want to poll periodically.
    the device is listed as:
    Code:
    lsusb | grep "Tiger Jet Network"
    Bus 002 Device 004: ID 06e6:c200 Tiger Jet Network, Inc. Internet Phone
    all I want to know is when its plugged in or not plugged in.
    how might I do that?

    Im just starting to read about polling, lsusb tells me what I want to know, but I dont know how to put it into a true false statement in a bash script.
    Code:
    #!/bin/bash
    
    result=0
    result=`lsusb | grep -e "Tiger Jet Network, Inc. Internet Phone"`
    if $result !=0
    then 
    	echo "Great execute some code" 
    		else
    			echo "Device was unpluged"
    			exit
    fi
    That is what I had tried thus far, but it doesnt work.
    can someone point me in the direction of being able to execute code if
    lsusb says my device is plugged in?
    Last edited by conradin; October 5th, 2012 at 02:29 PM. Reason: cant spell / code
    ~Conradin~

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •