Apart from the problem cited by bart, there are a couple other syntax errors in the code you posted. This first line inside the if ($match) block is missing something:
($shortname) = ($device =~ /^\d+\./ $interface =~ /^\d+\./) ? ...
It's checking two regex matches, but there should be an "and" or "or" (or && or ||) between them -- or else there should be only one regex test. (Do you know what the intention is there? I don't.)
Then this line just after the lengthy comment is obviously bad:
$rc = sendtrap("$device", "$summary", "$descr", $intfc" "NODE_DOWN");
You're missing a comma before "NODE_DOWN", and you have an odd number of quotation marks. (You could actually get rid of all the double-quotes in that line except for the ones around "NODE_DOWN", but you need the missing comma.)
Running the script without fixing those (and the line pointed to by bart) will just generate a bunch of syntax errors. Is that what you meant by "I cannot get this to work correctly"? Or did you make mistakes in posting your code, and the version you're actually running has some other problem(s)? |