amoura has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks in my script I am trying to verfiy the drive litter and locate under which dirve i am : I try to use
system(qq(pwd));
it is not doing what exactlly I want when running my script using cygwin ,, it is ok with DOS though ,,, so is there a command in perl or different way of checking you current drive.. thanks for any help

Edit kudra, 2002-08-02 Changed title: s/litter/letter/

Replies are listed 'Best First'.
Re: check a drive litter
by DamnDirtyApe (Curate) on Aug 01, 2002 at 16:48 UTC

    I would look at the Cwd module if I were you. It works great in Unix (not sure about Windows, but certainly worth a try.)


    _______________
    D a m n D i r t y A p e
    Home Node | Email

      It works under win32 as well; just be aware that the directory name returned is formatted using slashes instead of backslashes (ie. perl style rather than windows style). E.g. c:/sw/perl

Re: check a drive litter
by rsteinke (Scribe) on Aug 01, 2002 at 18:27 UTC

    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
Re: check a drive litter
by Cine (Friar) on Aug 01, 2002 at 18:21 UTC
    Your drive is all rubish, you can use format c: to remove all your litter ;) (Replace c: with the drive you have filled with litter)
    Sorry couldn't help myself

    T I M T O W T D I