kudithipudi
IS-IT--Management
Hello Guys,
Am staring at this peace of code for 2 hours now and have finally given up
#!/usr/bin/perl
use strict;
my $infile = 'machines.txt';
my $outfile = 'results.txt';
my @machines;
my ($machine, $CaptureSize, $FileSize);
my $datadir = '/home/migrate/data';
open(READ,"$infile"
;
@machines = <READ>;
close(READ);
open(WRITE,">$outfile"
;
chdir($datadir);
foreach $machine(@machines)
{
chomp($machine);
if (chdir($machine))
{
$CaptureSize = `du -ch CAPTURE.* | grep total`;
$FileSize = `du -ch *.MCF | grep total`;
print WRITE "$machine $CaptureSize $FileSize\n";
}
chdir($datadir);
}
close(WRITE);
I am trying to parse a directory and get the size of some particular files in that directory. The code runs without any issues, but does not write anything to the results.txt file. What am I doing wrong here?
Thanks for the help.
- V.
Am staring at this peace of code for 2 hours now and have finally given up
#!/usr/bin/perl
use strict;
my $infile = 'machines.txt';
my $outfile = 'results.txt';
my @machines;
my ($machine, $CaptureSize, $FileSize);
my $datadir = '/home/migrate/data';
open(READ,"$infile"
@machines = <READ>;
close(READ);
open(WRITE,">$outfile"
chdir($datadir);
foreach $machine(@machines)
{
chomp($machine);
if (chdir($machine))
{
$CaptureSize = `du -ch CAPTURE.* | grep total`;
$FileSize = `du -ch *.MCF | grep total`;
print WRITE "$machine $CaptureSize $FileSize\n";
}
chdir($datadir);
}
close(WRITE);
I am trying to parse a directory and get the size of some particular files in that directory. The code runs without any issues, but does not write anything to the results.txt file. What am I doing wrong here?
Thanks for the help.
- V.