in reply to Re: Does Perl Support Absolute paths
in thread Does Perl Support Absolute paths

Why shell out if you can do this from within the script, with better chance to handle errors (if any).

use Win32::FileOp qw(Map); Map 'H:' => '\\\\server\\share', {persistent => 1} or die "Failed to map the drive: $^E\n"

Replies are listed 'Best First'.
Re^3: Does Perl Support Absolute paths
by Ashes.cfg (Initiate) on Nov 08, 2007 at 03:51 UTC
    Thanks a lot monks regarding this issue. I would rather run it directly from the UNC path(and not absolute path..thank you for that too) as there would be 10-15users running the script from their WorkMachine and I dont knw which drive is available for them to map it on. I will definitely try this when I reach work tommorrow. Sincere Thanks Ashes.cfg

      Sure, just make sure you have enough backslashes :-)

      You should only need to map the share if you have a program that doesn't accept UNCs or if you need to run a program with the path being the current directory. Because current directory can't be UNC.

      If you do happen to need that you can find out what drives are mapped and which ones are free by Win32::FileOp::Mapped(), or you can call the Map() like this:

      my $drive = Map '\\\\server\\share'; chdir("$drive\\some\\directory");

      Hello Monks, Well I am @ work now and i tried doing what you told.. UNC path is getting accepted...its just that the script gives me the following problem "CMD.EXE was started with the above path as the current directory. UNC paths are not supported.Defaulting to Windows directory" Above path is the UNC path.