diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-02-29 12:15:52 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-03-03 15:19:17 -0800 |
commit | b70c02f69ea5abf32e0ebe4781e6cd396a4a1dd4 (patch) | |
tree | f6d0143b8c57a50c6150039ea0b473a06a262c32 /scripts/firewall/vyatta-show-firewall.pl | |
parent | b8eef1d2c21728e7835b01058d3080c035162cae (diff) | |
download | vyatta-op-firewall-b70c02f69ea5abf32e0ebe4781e6cd396a4a1dd4.tar.gz vyatta-op-firewall-b70c02f69ea5abf32e0ebe4781e6cd396a4a1dd4.zip |
use exec rather than open with path
This avoids a number of future problems with bareword filehandles.
See Perl Best Practices (Chapter 10)
Diffstat (limited to 'scripts/firewall/vyatta-show-firewall.pl')
-rwxr-xr-x | scripts/firewall/vyatta-show-firewall.pl | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/scripts/firewall/vyatta-show-firewall.pl b/scripts/firewall/vyatta-show-firewall.pl index 4995a09..78e6b68 100755 --- a/scripts/firewall/vyatta-show-firewall.pl +++ b/scripts/firewall/vyatta-show-firewall.pl @@ -26,15 +26,17 @@ sub show_chain { my $chain = shift; my $fh = shift; - open(STATS, "/sbin/iptables -L $chain -vn |") or exit 1; + open my $iptables, "-|" + or exec "sudo", "/sbin/iptables", "-L", $chain, "-vn" + or exit 1; my @stats = (); - while (<STATS>) { + while (<$iptables>) { if (!/^\s*(\d+[KMG]?)\s+(\d+[KMG]?)\s/) { next; } push @stats, ($1, $2); } - close STATS; + close $iptables; print $fh "<opcommand name='firewallrules'><format type='row'>\n"; my $config = new VyattaConfig; |