This does it, thanks for the help Perl Monks!
# $destination is the full unc path to the share directory # $extract is the full path the the individual file to be copied my $drive = netUse ($destination); copyDat ($extract, $drive); sub netUse { my @net_use_output; my $output; chomp $_[0]; $_ = $1 if($_[0]=~/(.*)\\$/); print "\nnet use \* \"$_[0]\""; #my $output = `net use \* \"$_[0]\" 2>&1|`; open TASK, "net use \* \"$_[0]\" 2>&1|" or die "cannot map $_[0]" +; while (<TASK>) { print "\n"; print; #chomp; #chop; push (@net_use_output, $_); #return $_; } print join(", ", @net_use_output); print "\n"; print "\n"; print "-----\n"; print @net_use_output[0]; $output = $2 if(@net_use_output[0]=~/^(Drive\s)([A-Z])\:(.*)$/); print "\n"; print "\n"; print "-----\n"; print $output; return $output; } sub copyDat { my $file = basename($_[0]); my $path = dirname($_[0]); #$path .= "\\"; #This one's for James print "\n File: $file \n\n"; print "\n Dirname: $path \n\n"; #chomp $_[1]; #my $map = $_[1]; #my $map = $1 if($map=~/(.*)\\$/); print "\nROBOCOPY \"$path\" $_[1]\:\\ $file /B \n\n"; open TASK, "ROBOCOPY \"$path\" $_[1]\:\\ $file /B 2>&1|" or die "c +annot $!"; while (<TASK>) { print; #return $_; } print "\nnet use $_[1]\:\\ /delete \n\n"; open TASK2, "net use $_[1]\: /delete 2>&1|" or die "cannot $!"; while (<TASK2>) { print; #return $_; } }
- 3dbc

In reply to Re^2: perl robocopy to temp mapped drive. by 3dbc
in thread perl robocopy to temp mapped drive. by 3dbc

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.