CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Need DirSelect for unmounted network shares


New User

Jun 14, 2011, 11:11 PM

Post #1 of 1 (531 views)
Need DirSelect for unmounted network shares Can't Post

Hi all,
I need to write a script to copy folders from one network share to another. To do this the user has to choose the directory (only directories, no single files) which he wants to copy. This network shares are not mountet on the client systems (WinXP and Win7). Mounting is no option for me, because i don't know which drive letters are already in use.

I tried to configure a user selection with DirSelect ( ) but this doesn't work for unmounted NFS shares. Afterwards i tried to build something on my own with Find and Tree.


use strict;
use warnings;
use Tk;
use Tk::Tree;
use File::Find;

my $root = '//srv0c001/io$/';
my @aFolders;

# Create Gui
my $mw = MainWindow -> new;
my $text = 'Doubleclick or <Enter> line';
$mw -> Label (-textvariable => \$text) -> pack (-side => 'top');
my $tree = $mw -> Tree (-command => sub {$text = shift}, -width => 30, -height => 20) -> pack (-anchor => 'nw');

# Search for Subdirectories
find(\&wanted, $root);
@aFolders = sort(@aFolders);

# add directories to tree
my @t = split (/\./, $_);
$tree->add($_, -text => $t[-1]);


$mw -> Button (-text => 'Exit', -command => sub {exit}) -> pack ();


sub wanted {
if (-d) {
$File::Find::name =~ s/.*io$\/?//g;
$File::Find::name =~ s/\//\./g;
if ($File::Find::name ne '') {
push(@aFolders, "$File::Find::name");

Problem is that:
1. My script is way to slow. There are about 30000 subfolders and 200000 files in the share. I don't know how long it takes to check all of these, but it's way to long.

2. I want the folder selection as a subroutine so that only the selected path is returned. But i don't know how to do this

Short way to say it:
I need something like DirSelect which works for unmounted network shares

By the way: this is my first perl project. I normally use other scripting languages, but in this case i need to do it in perl. Might be that there is a solution for my problem out there, but i havn't find it

Thanks in advance for anybody who's trying to help



PS: Sorry for my bad english


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives