C
Cosmic Cruizer
I'm having trouble getting file stats from files on remote servers. All the
filenames get printed from within the if statement, but I am not getting
anything for the file size (or any other stat I try). Doing a print on
$target_file returns the full path and filename.
Any suggestions?
foreach (@server_list) {
print "$_ \n";
system("net use q: $_ /USER:$user $password");
opendir DIR, $file_path or die "Cannot open: $!";
my @files = grep { /GLC[0-9a-zA-Z]*\.tmp/ } readdir DIR;
for my $file ( @files ) {
my $target_file = $file_path . $file;
if (-e $target_file) {
$size = (stat($target_file))[7]; # Use 8th element of stat
print " $file \t $size\n";
}
}
closedir DIR;
system("net use q: /delete");
}
filenames get printed from within the if statement, but I am not getting
anything for the file size (or any other stat I try). Doing a print on
$target_file returns the full path and filename.
Any suggestions?
foreach (@server_list) {
print "$_ \n";
system("net use q: $_ /USER:$user $password");
opendir DIR, $file_path or die "Cannot open: $!";
my @files = grep { /GLC[0-9a-zA-Z]*\.tmp/ } readdir DIR;
for my $file ( @files ) {
my $target_file = $file_path . $file;
if (-e $target_file) {
$size = (stat($target_file))[7]; # Use 8th element of stat
print " $file \t $size\n";
}
}
closedir DIR;
system("net use q: /delete");
}