in reply to Windows Net Use
You can avoid splitting alltogether if you search for your share in the output of net use and then return the first word of that line.
use strict; my $inputDirectory = '"\\\\10.81.253.70\\file data\\query files"'; # need to dublicate each \ in string $inputDirectory =~ s|\\|\\\\|g; my @lines = `net use`; foreach my $line ( @lines ) { next unless $line =~ m|$inputDirectory|; $line =~ /(^\S+)/; print $1; }
This also overcomes the issue that the output of net use is sometimes split into two lines when it is too long. The output of net use sometime returns no status as well, which might be a problem or not.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Windows Net Use
by Anonymous Monk on Mar 28, 2013 at 09:05 UTC | |
by hdb (Monsignor) on Mar 28, 2013 at 09:51 UTC | |
by Anonymous Monk on Mar 28, 2013 at 10:08 UTC | |
by hdb (Monsignor) on Mar 28, 2013 at 10:44 UTC | |
by 7stud (Deacon) on Mar 28, 2013 at 09:45 UTC |
In Section
Seekers of Perl Wisdom