Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hm, only some heuristics - very fragile, but maybe they work for you:

Output of mount: a mounted CD/DVD has usually a filetype of iso9660 or udf and an ro attribute. USB sticks, -drives, iPods, etc. are often mounted with the flush attribute and might have filetype vfat (not sure: ntfs, msdos).

pb> mount | perl -ne '@mnt = split /\s+/; print "Stick? $mnt[0] $mnt[2 +]\n" if $mnt[4] =~ /vfat|msdos|ntfs/ && $mnt[5] =~ /flush/;' Stick? /dev/sdd1 /media/BLUESTICK Stick? /dev/sde /media/IPOD pb> mount | perl -ne '@mnt = split /\s+/; print "CD/DVD? $mnt[0] $mnt[ +2]\n" if $mnt[4] =~ /udf|iso\d+/ && $mnt[5] =~ /ro/;' CD/DVD? /dev/sr0 /media/SOYLENT_GREEN CD/DVD? /dev/sr1 /media/IX0712
.oO(mmmmmhhh Soylent Green™...)

lsusb -v lists the USB devices currently attached but not necessarily mounted. Check e.g. for attribute bInterfaceClass 8 Mass Storage. Though, you might find empty memory card readers, iPODs, everything that has a filesystem interface...

pb> lsusb -v 2>/dev/null | \ perl -ne '$dev=$_ if /^Bus/; print $dev if /bInterfaceClass\s+8\D/ +' Bus 002 Device 006: ID 05ac:1301 Apple Computer, Inc. Bus 002 Device 006: ID 05ac:1301 Apple Computer, Inc. Bus 002 Device 005: ID 1307:0163 Bus 002 Device 004: ID 05e3:070e Genesys Logic, Inc.

Use with care.

In reply to Re: Detect Plugged USB Flash Drive / CD in CDROM Drive by Perlbotics
in thread Detect Plugged USB Flash Drive / CD in CDROM Drive by renegadex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-19 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found