develooper Front page | perl.beginners | Postings from February 2002

network file directories and directory names with spaces

Thread Next
From:
Eric Peers
Date:
February 28, 2002 12:53
Subject:
network file directories and directory names with spaces
Message ID:
001201c1c099$f5397fc0$0c82940a@usa.int
Based on a lack of replies to my post of yesterday, I'm assuming that perl
running on a Windows machine can not access a Windows directory with spaces
in the directory path (i.e. D:\scripts\perl script files\).  I've been given
permission to change the spaces to underscores, so for the moment that
problem is solved though it would be nice know whether perl can read
directories with spaces in the path.  I admit that I have not tried the
opendir command to see if this solves the problem.

My second question is whether perl can read across a Windows network?  I've
tried \\\\wvit9\\work\\ and have mapped the network drive to the web server
in an attempt to get the perl script to read the files on a remote server
with no success.  So, what obvious thing am I missing?

Installing perl on the remote system would solve the remote directory
problem, however there are issues that prevent me from installing
ActivePerl, so I'm looking for of globbing the files across the network.

Any thoughts will be helpful.  Even if its no, you can't do this..


Code samples:

#! /usr/bin/perl -w

use strict;
use CGI qw(:standard);
use File::Basename;

my $dir =
"D:\\Inetpub\\wwwroot\\kfvstart\\intranet\\Eric\\Logos\\Active_Logos_600_dpi
\\";  #This works.
# these do not work
#my $dir = "G:\\E-drive\\Logos\\";
#my $dir = "\\\\Logoserver\\Logos\\";
#my $dir = "\\\\WVPCIT9\\Work\\";
#my $dir = "H:\\"; # The work directory on my PC.


The heart of the search:

    $criteria = param('criteria');
    $search = $dir . $criteria;
    while ($files = <$search*>) {
        $counter++;
        $files =~ s#.*/##; #remove part before last slash
        my ($name, $directory, $extension) = fileparse($files,'\..*');
        my $filename = $name . $extension;
        my $uri = "http://wv1svlg001/Active%20Logos%20600%20dpi/" .
$filename;
        if ($counter % 2) {
            print '<tr bgcolor="#e8e8e8"><td nowrap>';
        } else {
            print '<tr><td nowrap>';
        }
        print "<a href=$uri>$filename</a><br>";
        print '</td></tr>';
    }

Thanks,

Eric


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About