O great monks,

How does one deal with files over a fileshare on a Win32 system? I need to do things like listing directories, determining files vs directories, copying/moving/deleting files, getting file dates, and the like. I've gotten reasonably proficient at this stuff on Unix systems by using Net::FTP, Net::Telnet, and/or the file test operators, but most of that doesn't apply here. The Win32 server(s) I'm dealing with aren't running FTP or Telnet daemons, and many of the standard file/directory functions seem to only work on local files/directories. For example:
$dir = "\\\\server\\share"; @files = <$dir/*>; print "$_\n" for @files;

This returns nothing, presumably because the angle operator only works on local files. (Correct?)

$dir = "\\\\server\\share"; opendir DH, $dir or die "Cannot open $dir: $!"; @files = ( readdir DH ); print "$_\n" for @files;

This prints a directory listing, but the file test operators (-d, -M, etc.) can't be used to determine files from directories, timestamps, and such.
$dir = "\\\\server\\share"; @files = `dir $dir /b /a-d`; print @files;

This works to list only the remote files, but please don't tell me I need to call DOS commands for this kind of stuff! If I want to copy/move/delete remote files, will I need to use external commands again?

There's clearly a huge Win32 hole in my Perl knowledge here. There must be modules to help with this, but I haven't found them. As always, I appreciate your advice/experience/gentle beatings in the right direction.

-E

In reply to Manipulating files on Windows shares by EyeOpener

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.