Re: Shame on me poorr newbie " unexpected kend"


#1

loop do
end
else
store += 1
end
end
end

and you can simplify this even more:

def ask(msg)
loop do
print "#{msg} [y/n]: "
response = gets().strip
return true if response == ‘y’
return false if response == ‘n’
puts “Invalid response. Please enter y or n”
end
end

def find_device
puts “We are now trying to find the device”
Dir["/proc/scsi/usb-storage/*"].each do |usb_dev|
usb = File.read(usb_dev)
return usb if ask(“Found in #{usb_dev}: #{usb}. Is this your
device?”)
end && nil
end

procdata = find_device

cheers

Simon

p.s.: I have no /proc/scsi/usb-storage (win2000) so this is untested.


#2

On 4/13/06, Kroeger, Simon (ext) removed_email_address@domain.invalid wrote:

 end
   @procdata = usb

def ask(msg)
puts “We are now trying to find the device”

cheers

Simon

p.s.: I have no /proc/scsi/usb-storage (win2000) so this is untested.

Tested and am glad to get the following:
$ ruby find_usbdev.rb
We are now trying to find the device
Found in /proc/scsi/usb-storage/3: Host scsi3: usb-storage
Vendor: SanDisk Corporation
Product: Cruzer Mini
Serial Number: 2004351462080892ebd0
Protocol: Transparent SCSI
Transport: Bulk
Quirks:
. Is this your
device? [y/n]: y

Prasad