Detecting USB Flash Devices (plugged and hot-plugged)


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Detecting USB Flash Devices (plugged and hot-plugged)
# 1  
Old 06-02-2008
Detecting USB Flash Devices (plugged and hot-plugged)

I am trying to script the process of looking for a usb-key inside another application. I have gotten some success by recording "ls /dev" and comparing it to a new "ls /dev" periodically.

However this has made it so I have to prompt the user to take out the usb-key (if plugged in), let my script know (so it can "ls /dev" a baseline), plug the usb-key back in (so it can "ls /dev" a comparison after 3 second sleep), and finally loop through mount attempts till I find one that doesn't error (of the 2-3 detected - like sdb, sdb1, sdb2 - only sdb1 is actually the drive - though all three appear), and if multiple are mountable (cause who knows what else could have simultaneously happened in the /dev directory), ask the user to pick.

Is there a better way? (no hotplug [the app] support, sorry)
# 2  
Old 06-02-2008
If this is a HAL system, look into lshal -m
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Regular Expressions : grab flash devices

I know its an art and it takes a little time .. but is there a better way to do this ? (sup-)?boot(disk|flash)|flash\d*|disk\d Thanks in advance Pop (1 Reply)
Discussion started by: popeye
1 Replies

2. Solaris

/devices/pseudo/md - detecting problems?

Got an informix DB that won't start because DB chunk is offline. Its a raw device. See below:- lrwxrwxrwx 1 root root 29 Feb 6 2013 /dev/DB -> /devices/pseudo/md@0:0,10,raw How do I tell what that refers to? I've checked metadb and metastat and cant see any issues? (2 Replies)
Discussion started by: psychocandy
2 Replies

3. Solaris

Detecting wirelss USB Adapter

Hi, i try to plug in my USB wireless adapter to my sun solaris server. However, it cannot detect it. How do i set it so that it can detect it? (1 Reply)
Discussion started by: lkyow
1 Replies

4. Shell Programming and Scripting

Detecting A USB Storage Device From A Script

I need a way to reliably detect a USB storage device from a bash script. I know how to use 'lsusb' to list the USB devices - but then how can I match a device listed in 'lsusb' output to an actual disk device? Is there some way to map one to the other? Any help appreciated. (3 Replies)
Discussion started by: dmaddox099
3 Replies

5. SCO

Occasional Core Dump with hot swap USB Thumb Drive

Hello Unix World, I've been having this issue for the longest time. Here is my setup OS: SCO OpenServer 6.0 with mp4, mp3 Server: Dell PowerEdge 840, 800, 2900 USB Stick: Patriot 16GB High Speed, and many other different brands. Occasinaly while system is running and USB is pluged in the... (0 Replies)
Discussion started by: miles556
0 Replies

6. BSD

Detecting usb stick in freebsd

I inserted a 8GB usb stick in a number of machine with FreeBSD 7.1, but the medium was not detected: $ dmesg | grep MB usable memory = 4263022592 (4065 MB) avail memory = 4082540544 (3893 MB) pci0: <serial bus, SMBus> at device 31.3 (no driver attached) ad0: 238475MB <WDC WD2500BEVT-00ZCT0... (6 Replies)
Discussion started by: figaro
6 Replies

7. Shell Programming and Scripting

disableing my USB devices using a script

hi guys I would like to disable my USB devices using a shell script(Linux machine) i.e(hoteplug,kernelpcmciacs,pcmciacs) Kindly suggest me at the earliest Thnks in advance regards ash (0 Replies)
Discussion started by: whizkidash
0 Replies

8. Solaris

Can this be disabled? interface turned of when console cable plugged in.

Whenever I plug a console cable into the back of my sunfire v240 it automatically turns of bge0 which is the interface that connects to my network and the only interface i use on the box (and it stays shutdown until reboot). Is there anyway to stop this from happening or can someone please explain... (12 Replies)
Discussion started by: kingdbag
12 Replies

9. Red Hat

USB Devices

I am trying to get a flash card reader to work with my machine. My question is, are all of my USB ports screwed up? Do I need to buy a seperate USB controller? I does not appear that the onboard USB ports work. In trying to get it to work, I typed cat /proc/scsi/scsi and got this: # cat... (2 Replies)
Discussion started by: davidkretsch
2 Replies

10. UNIX for Advanced & Expert Users

USB Hot Plug Mandrake 9.0

I recently installed Mandrake Linux 9.0 on my intel machine, with a view to migrating completely from Windows within the next few months. First I need to get things working. My modem, sound card, scanner and printer all fail to work. This isn't going to put me off because I love the interface... (1 Reply)
Discussion started by: saabir
1 Replies
Login or Register to Ask a Question