diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vyatta-tshark-interface-port.pl | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/scripts/vyatta-tshark-interface-port.pl b/scripts/vyatta-tshark-interface-port.pl index aa750e5..47088f9 100755 --- a/scripts/vyatta-tshark-interface-port.pl +++ b/scripts/vyatta-tshark-interface-port.pl @@ -31,7 +31,7 @@ use warnings; sub check_if_interface_is_tsharkable { my $interface = shift; - my @grep_tshark_interfaces = `sudo /usr/bin/tshark -D | grep $interface`; + my @grep_tshark_interfaces = `/usr/bin/tshark -D | grep $interface`; my $any_interface; for my $count (0 .. $#grep_tshark_interfaces) { @@ -48,8 +48,7 @@ sub check_if_interface_is_tsharkable { } } if ($exact_match == 0 || $any_interface eq 'any') { - print "Unable to capture traffic on $interface\n"; - exit 1; + die "Unable to capture traffic on $interface\n"; } } @@ -62,31 +61,11 @@ my $intf = $ARGV[0]; check_if_interface_is_tsharkable($intf); if ($#ARGV > 0){ - my $port = $ARGV[1]; - my $not_port = $ARGV[2]; - if ($port =~ /[a-zA-Z]/){ - print "Port number has to be numeric. Allowed values: <1-65535>\n"; - exit 1; - } else { - if (($port > 0) and ($port < 65536)){ - if ($not_port == 0){ - print "Capturing traffic on $intf port $port ...\n"; - exec "sudo /usr/bin/tshark -n -i $intf port $port 2> /dev/null"; - } else { - print "Capturing traffic on $intf excluding port $port ...\n"; - exec "sudo /usr/bin/tshark -n -i $intf not port $port 2> /dev/null"; - } - } else { - print "Invalid port number. Allowed values: <1-65535>\n"; - exit 1; - } - - } + my $filter = $ARGV[1]; + print "Capturing traffic on $intf $filter ...\n"; + exec "sudo /usr/bin/tshark -n -i $intf $filter"; } else { - print "Capturing traffic on $intf ...\n"; - exec "sudo /usr/bin/tshark -n -i $intf 2> /dev/null"; + print "Capturing traffic on $intf ...\n"; + exec "sudo /usr/bin/tshark -n -i $intf"; } -exit 0; - -#end of file |