Steve_BZ has asked for the wisdom of the Perl Monks concerning the following question:
Hi Guys,
I'm trying to open a USB drive on Kubuntu to write to, but clearly I need to find out which drives are available first. The following code works fine after the drives have been examined using dolphin or whatever, but otherwise not. So I can plug in a USB drive and run the code and I get negative results. If I then inspect a drive with dolphin and run the code, the drive is detected. I guess I need to mount the drive somehow, but how?
Advice welcome.
Code follows.
Thanks
Steve
use strict; use warnings; package dir_test; for (my $i=0;$i<=5;$i++){ if ($i==0 and opendir (MYDIR, "/media/disk/.")){ print "/media/disk/","\n"; closedir (MYDIR); } else { if ($i>0 and opendir (MYDIR, "/media/disk-$i/.")){ print "/media/disk-$i/","\n"; closedir (MYDIR); } else { print "not /media/disk-$i/","\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Opening a USB drive for storing info.
by davido (Cardinal) on May 23, 2011 at 02:52 UTC | |
by afoken (Chancellor) on May 23, 2011 at 09:15 UTC | |
by davido (Cardinal) on May 23, 2011 at 19:07 UTC | |
by Steve_BZ (Chaplain) on May 23, 2011 at 14:17 UTC | |
|
Re: Opening a USB drive for storing info.
by wind (Priest) on May 22, 2011 at 22:56 UTC | |
by Steve_BZ (Chaplain) on May 23, 2011 at 00:01 UTC | |
by Anonymous Monk on May 23, 2011 at 00:44 UTC |