in reply to Filesystem and SMB/NFS share Access
First of all, a couple of general recommendations to improve the code:
Always Use strict and warnings. Although your current program only needs a few fixups, those pragmas will help you avoid typos and other mistakes.
Use consistent indentation. perltidy can help.
Reduce repetitions. I would have written something like this:
sub exit_with_msg { my ($message,$returnid) = @_; print "CURRVALUE_STRING: $message\n"; print "RETURNID: $returnid\n"; exit 0; }
And then used it everywhere like e.g. exit_with_msg("a File-Path must be given",1);. This will shorten your code significantly.
In the same vein, you seem to be assigning to $Username and $Password twice, and I'm wondering if this is correct: $Password = $opt_s;
Now, moving on to your task, note that the core Perl module File::Spec is good for cross-platform handling of filenames. For example, you can use its splitpath method to find out the volume of a path, instead of manually splitting like you are currently doing.
As for your main question, unfortunately I'm a bit rusty on my Perl+Windows+UNC. So it's a little unclear to me how you want to go about testing the files on network shares: do you want to map the shares to network drives? A quick search found several threads with information:
For example, most of these threads mention Win32::FileOp as a possibility. It's also possible to shell out to run commands like NET USE, but running external commands is usually a tricky topic, which I wrote about at length here (in this case for example, I might recommend the latest version of IPC::Run3 because it should provide for the "best" quoting of command arguments).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Filesystem and SMB/NFS share Access
by PerlingAround (Novice) on Oct 10, 2018 at 07:38 UTC | |
by Anonymous Monk on Oct 19, 2018 at 10:43 UTC |