#!/usr/bin/perl
my $greeting = $ARGV[0] // '********** PERL RECEIVED A NOTIFICATION:';
sub my_receiver {
print $greeting, "\n";
}
NetSNMP::TrapReceiver::register("all", \&my_receiver) || warn "failed to register\n";
print STDERR "Loaded the example perl snmptrapd handler\n";
####
perl do "/usr/local/share/snmp/mytrapd.pl hello";
####
That won't work. The perl 'do' command only expects a filename.
Instead, you can either define a subroutine in the file rather than have
the file itself do something. IE, in the file if you put:
sub foo {
print "$_[0]\n";
}
and then put these lines in the snmptrapd.conf file:
perl do /path/to/script
perl foo("hello world");
perl foo("now I am passing something different");