"; local $tailcmd = $config{'tail_cmd'} || "tail -n LINES"; $tailcmd =~ s/LINES/$lines/g; my ($safe_proc_out, $safe_proc_out_got); if ($filter ne "") { # Are we supposed to filter anything? Then use grep. local @cats; if ($cmd) { # Getting output from a command push(@cats, $cmd); } elsif ($config{'compressed'}) { # All compressed versions foreach $l (&all_log_files($file)) { $c = &catter_command($l); push(@cats, $c) if ($c); } } else { # Just the one log @cats = ( "cat ".quotemeta($file) ); } $cat = "(".join(" ; ", @cats).")"; if ($reverse) { $tailcmd .= " | tac" if ($cmd !~ /journalctl/); } $eflag = $gconfig{'os_type'} =~ /-linux/ ? "-E" : ""; $dashflag = $gconfig{'os_type'} =~ /-linux/ ? "--" : ""; if (@cats) { my $fcmd; if ($cmd =~ /journalctl/) { $fcmd = "$cmd --grep $filter"; } else { $fcmd = "$cat | grep -i -a $eflag $dashflag $filter ". "| $tailcmd"; } open(my $output_fh, '>', \$safe_proc_out); $safe_proc_out_got = &proc::safe_process_exec( $fcmd, 0, 0, $output_fh, undef, 1, 0, undef, 1); close($output_fh); print $safe_proc_out if ($safe_proc_out !~ /-- No entries --/m); } else { $safe_proc_out_got = undef; } } else { # Not filtering .. so cat the most recent non-empty file if ($cmd) { # Getting output from a command $fullcmd = $cmd.($cmd =~ /journalctl/ ? "" : (" | ".$tailcmd)); } elsif ($config{'compressed'}) { # Cat all compressed files local @cats; $total = 0; foreach $l (reverse(&all_log_files($file))) { next if (!-s $l); $c = &catter_command($l); if ($c) { $len = int(&backquote_command( "$c | wc -l")); $total += $len; push(@cats, $c); last if ($total > $in{'lines'}); } } if (@cats) { $cat = "(".join(" ; ", reverse(@cats)).")"; $fullcmd = $cat." | ".$tailcmd; } else { $fullcmd = undef; } } else { # Just run tail on the file $fullcmd = $tailcmd." ".quotemeta($file); } if ($reverse && $fullcmd) { $fullcmd .= " | tac" if ($fullcmd !~ /journalctl/); } if ($fullcmd) { open(my $output_fh, '>', \$safe_proc_out); $safe_proc_out_got = &proc::safe_process_exec( $fullcmd, 0, 0, $output_fh, undef, 1, 0, undef, 1); close($output_fh); print $safe_proc_out if ($safe_proc_out !~ /-- No entries --/m); } else { $safe_proc_out_got = undef; } } print "$text{'view_empty'}\n" if (!$safe_proc_out_got || $safe_proc_out =~ /-- No entries --/m); print "
"; print "$text{'view_loading'}\n"; print "