Greetings, esteemed monks!

I'm fairly fluent in Linux Perl but working in Windows is driving me batty.

My apologies for the redundant title, but I didn't even know what a UNC path was until 30 minutes ago!

So I've been tasked with writing a script that would be trivial in Linux, but is causing me headaches in Windows.

The idea is that every evening before they leave, some of the bigwigs need to copy a bunch of stuff onto their memory sticks. It's emergency information kind of stuff. The current practice is to manually delete everything and re-copy it manually using Windows Explorer. That's fairly tedious. Enter Perl; it's doable as an icon they can double click on their desktop or even in the quicklaunch, I assume. The delete/re-copy an OK option but ideally I'd also like to make it more of a sync than a wipe and copy. I think the total amount of stuff is about 200-300 MB.

Also, ideally, I would use UNC paths as while each executive has the requisite drive mapped, I am not sure they're all the same letter. We can safely assume that the memory stick is D: for now.

So I originally tried

#Two-click copying of files to USB memory stick for executive staff #JWC started 5/30/06 #Assumptions: Memory stick is always D:, can use absolute path to get +to contin stuff use File::Copy; use File::Find; # for the convenience of &wanted calls, including -eval statements: use vars qw/*name *dir *prune/; *name = *File::Find::name; *dir = *File::Find::dir; *prune = *File::Find::prune; sub wanted{}; $status1=finddepth(\&wanted,"D:\\"); sub wanted{ print "deleting $name:\n"; if (-f $name){ unlink($name); }elsif (-d $name){ rmdir($name); } } $source="\\\\server\\dir\\files\\"; $dest="D:\\"; if (-e $source ){ print "found $source. \n"; } if (-e $dest ){ print "found $dest. \n"; } $status=system("xcopy $source $dest"); print "Status of copy is $status: $!";
And the delete part works like a charm but the copy part does not. The program passes the -e tests but xcopy fails with invalid path, status 1024 (I can't even copy and paste from the darn DOS window...)

In the chatterbox bart and others spoke of authentication issues and not being able to use full UNC paths as arguments to xcopy. I wouldn't mind programmatically mapping a drive, but it may be easier to either customize the script for each person or just make sure everyone uses Q: or whatever for the contingency stuff.

I sincerely appreciate any and all advice/solutions/commiseration!

T

_________________________________________________________________________________
Without me, it's just aweso


In reply to How to sync a UNC path to a USB memory stick in Windows? by OfficeLinebacker

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.