From 1b1f2377086a1eae05fc707ef63e0f436aaf08cc Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Thu, 25 Jul 2013 16:08:01 -0300 Subject: preserve header when filtering --- config/openbgpd/openbgpd_status.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/openbgpd/openbgpd_status.php b/config/openbgpd/openbgpd_status.php index 68836b21..c7987ec4 100644 --- a/config/openbgpd/openbgpd_status.php +++ b/config/openbgpd/openbgpd_status.php @@ -61,8 +61,10 @@ include("head.inc"); function doCmdT($command, $limit = "all", $filter = "", $header_size = 0) { $grepline = ""; - if (!empty($filter)) - $grepline = " | /usr/bin/grep " . escapeshellarg(htmlspecialchars($filter)); + if (!empty($filter)) { + $ini = ($header_size > 0 ? $header_size+1 : 1); + $grepline = " | /usr/bin/sed -e '{$ini},\$ { /" . escapeshellarg(htmlspecialchars($filter)) . "/!d; };'"; + } if (is_numeric($limit) && $limit > 0) { $limit += $header_size; $headline = " | /usr/bin/head -n {$limit}"; -- cgit v1.2.3