summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-09-17 15:23:44 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-09-17 15:23:44 -0700
commitce9c3ff84c4482fbf95c001a26ee9ccdc332e027 (patch)
tree9d76335d8e7e2b81dcce5a5eea159e06dcb4e868 /scripts
parent8e988dec3b0cd86c58a8d2222e0b142b9b684fa8 (diff)
downloadvyatta-op-ce9c3ff84c4482fbf95c001a26ee9ccdc332e027.tar.gz
vyatta-op-ce9c3ff84c4482fbf95c001a26ee9ccdc332e027.zip
Show all interfaces
Rework perl code to show all interfaces in system. Bugfix 3563
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-show-interfaces.pl19
1 files changed, 10 insertions, 9 deletions
diff --git a/scripts/vyatta-show-interfaces.pl b/scripts/vyatta-show-interfaces.pl
index 1e4038c..6f5d075 100755
--- a/scripts/vyatta-show-interfaces.pl
+++ b/scripts/vyatta-show-interfaces.pl
@@ -223,11 +223,16 @@ sub is_valid_intf_type {
}
sub get_intf_for_type {
- my $intf_type = shift;
+ my $type = shift;
+ my $sysnet = "/sys/class/net";
+ my $prefix = $type ? $intf_hash{$type} : '[^.]+';
+
+ opendir (my $dir, $sysnet) or die "can't open $sysnet";
+ my @list = grep { /^$prefix/ && -d "$sysnet/$_" } readdir($dir);
+ closedir $dir;
+ print join(', ', @list);
+ print "\n";
- my $intf_prefix = $intf_hash{$intf_type};
- my @list = `cd /sys/class/net; ls -d $intf_prefix\* 2> /dev/null`;
- chomp @list;
return @list;
}
@@ -403,12 +408,8 @@ if (defined $intf) {
}
@intf_list = get_intf_for_type($intf_type);
} else {
- #
# get all interfaces
- #
- foreach my $type (sort(keys (%intf_hash))) {
- push @intf_list, get_intf_for_type($type);
- }
+ @intf_list = get_intf_for_type();
}
if (! defined $action) {