I attempted to run net use * and pull the output but am getting errors.
#!/usr/bin/perl -w
use strict;
use warnings;
my $destination = qq(\\\\BLAH\\NESTED\\OBFUSCATED\.WITH SPECIAL_CHARS\
+\SHARE\\NAME\\DOWN\\DEEP);
netUse ($destination);
sub netUse {
my @net_use_output;
chomp $_[0];
$_ = $1 if($_[0]=~/(.*)\\$/);
print "\nnet use \* \"$_[0]\"";
open TASK, "net use \* \"$_[0]\"" or die "cannot map $_[0]";
while (<TASK>)
{
print;
#chomp;
#chop;
#push (@net_use_output, $_);
#return $_;
}
#print join(", ", @net_use_output);
#return @net_use_output;
}
above code always produces error:
cannot map \\BLAH\NESTED\OBFUSCATED.WITH SPECIAL_CHARS\SHARE\NAME\DOWN
+\DEEP at ..\
examples\blah.pl line 12, <TASK> line 1.
net use * "\\BLAH\NESTED\OBFUSCATED.WITH SPECIAL_CHARS\SHARE\NAME\DOWN
+\DEEP"
Even though copying and pasting the same command on the cmd shell works perfectly?