can anyone help
im after a quick solution to a problem at work. i wont bore you with details but i need to get the names of all the shares on a server into a file so i can add them to a .bat
file with the xcopy function.
with my little knowledge i managed to send the out put of the windows command "net view \\server" to a file net.log
then i thought ill use perl to take out all the junk and leave just share names then print them to a .bat with a
xcopy command for each share. as per the script below.
the problem im having is cutting out the unwanted stuff.
mainly white space new lines and the word Disk.
theres probably a much better way to do this!! any help either way would be great. thanks
#! usr/bin/perl -w
open FH, 'net.log';
@file=<FH>;
open (FILE,'>backup.bat');
select FILE;
foreach(@file){
@shares=split(m/\s+\n/, $_);
foreach(@shares){
@shares2=split(m/\s+Disk+/, $_);
print "xcopy /S \\\\rnb-pc-server\\@shares2 d:\\backup\\@shares2\n";
}
}
close FH;
close FILE;
im after a quick solution to a problem at work. i wont bore you with details but i need to get the names of all the shares on a server into a file so i can add them to a .bat
file with the xcopy function.
with my little knowledge i managed to send the out put of the windows command "net view \\server" to a file net.log
then i thought ill use perl to take out all the junk and leave just share names then print them to a .bat with a
xcopy command for each share. as per the script below.
the problem im having is cutting out the unwanted stuff.
mainly white space new lines and the word Disk.
theres probably a much better way to do this!! any help either way would be great. thanks
#! usr/bin/perl -w
open FH, 'net.log';
@file=<FH>;
open (FILE,'>backup.bat');
select FILE;
foreach(@file){
@shares=split(m/\s+\n/, $_);
foreach(@shares){
@shares2=split(m/\s+Disk+/, $_);
print "xcopy /S \\\\rnb-pc-server\\@shares2 d:\\backup\\@shares2\n";
}
}
close FH;
close FILE;