This got me thinking about how to do the corresponding thing on Unix (find the hardware device). The following succeeds on my (Linux) machine, but may have problems with trailing slashes on the directories returned by 'mount'.

#!/usr/bin/perl use strict; use warnings; my $mountlist = `mount`; my %mounts; $mounts{$2} = $1 while($mountlist =~ /(.*) on (.*) type.*\n/g); my $location = `pwd`; chomp $location; my $mount_dir = $location; $mount_dir =~ s#/[^/]*$## while $mount_dir && !$mounts{$mount_dir}; $mount_dir ||= '/'; # Add the 'trailing' slash back in if we're mounte +d as root print "Directory $location is on device $mounts{$mount_dir}\n";
Ron Steinke rsteinke@w-link.net

In reply to Re: check a drive litter by rsteinke
in thread check a drive letter by amoura

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.