Perl backticks not capturing output

1.3k views Asked by At

I have the following program snippet

my $nfdump_command = "nfdump -M /data/nfsen/profiles-data/live/upstream1  -T  -R ${syear}/${smonth}/${sday}/nfcapd.${syear}${smonth}${sday}0000:${eyear}/${emonth}/${eday}/nfcapd.${eyear}${emonth}${eday}2355 -n 100 -s ip/bytes -N -o csv -q | awk 'BEGIN { FS = \",\" } ; { if (NR > 1) print \$5, \$10 }'";
syslog("info", $nfdump_command);

my %args;
Nfcomm::socket_send_ok ($socket, \%args);
my @nfdump_output = `$nfdump_command`;
my %domain_name_to_bytes;
my %domain_name_to_ip_addresses;

syslog("info", Dumper(\@nfdump_output));

foreach my $a_line (@nfdump_output) {
    syslog("info", "LINE: " . $a_line);
}

Bug: @nfdump_output is empty. enter image description here

The $nfdump_command is correct and it printing output when ran individually

enter image description here

1

There are 1 answers

0
SurenNihalani On

This program was working for sometime and then it broke. Couldn't figure out why. After moving my development setup to another virtual machine, I found out that using absolute path to nfdump fixes it