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
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...)#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: $!";
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |