Hi All,
How I will read the output of the tail -F command in perl.
I have text file with below contains
file1.txt
1
2
3
4
$running=1;
sub openLog($)
{
(my $log) = @_;
local *LOG;
unless( open(LOG,$log." |") ) { print "unable to launch log: $!\n"; return 0; }
print "logging started with ".$log."\n";
return *LOG{IO};
}
while($running) {
my $pipe = openLog('tail -F file1.txt');
while (<$pipe>) { print $_ ;}
sleep 30;
}
After running the above script I am getting the below output and I am sending this output to the another server.
1
2
3
4
After that I have modified the file1.txt and added the below data.
file1.txt
1
2
3
4
5 #new data
6 #new data
7 #new data
I am getting the below output
1
2
3
4
5 #new data
6 #new data
7 #new data
How I will get below output after modifying the file1.txt , so I can send this output to the another server instead of sending again previous data
5 #new data
6 #new data
7 #new data
Please help me ..............