File: addMacAddressFile.pl

package info (click to toggle)
ntop 3%3A5.0.1%2Bdfsg1-2.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 15,720 kB
  • ctags: 11,480
  • sloc: ansic: 79,804; sh: 21,658; python: 1,948; awk: 1,504; perl: 971; makefile: 745; php: 123; xml: 71; sql: 13; sed: 11
file content (24 lines) | stat: -rwxr-xr-x 500 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl

# Specify the ntop.db file location
$ntop_db_file = "../ntop.db";

if($ARGV[0] eq "") {
  print "Usage: addMacAddressFile.pl <file name>\n";
  exit -1;
}

if(open(IN, "< $ARGV[0]")) {
  while(<IN>) {

    # Remove trailer '\n'
    if(substr($_, -1, 1) eq "\n") { chop($_); }
    
    ($mac, $value) = split (/\t/,$_);

    print "Adding $mac/$value\n";
    system("./addMacAddress $mac \"value\" $ntop_db_file");
  }
} else {
  print "FATAL ERROR: unable to read file $ARGV[0]\n";
}