I need your help , because I ´m not a perl specialist.
I want to trigger at an alarm a bash command. I have the following wiki page found :
http://zoneminder.readthedocs.org/en/la ... s-an-alarm
Code: Select all
#!/usr/bin/perl -w
use strict;
use ZoneMinder;
$| = 1;
zmDbgInit( "my-zm-script", level=>0, to_log=>0, to_syslog=>0, to_term=>1 );
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
my $sql = "select M.*, max(E.Id) as LastEventId from Monitors as M left join Events as E on M.Id = E.MonitorId where M.Function != 'None$
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or die( "Can't execute '$sql': ".$sth->errstr() );
my @monitors;
while ( my $monitor = $sth->fetchrow_hashref() )
{
push( @monitors, $monitor );
}
while( 1 )
{
foreach my $monitor ( @monitors )
{
next if ( !zmMemVerify( $monitor ) );
if ( my $last_event_id = zmHasAlarmed( $monitor, $monitor->{LastEventId} ) )
{
$monitor->{LastEventId} = $last_event_id;
print( "Monitor ".$monitor->{Name}." has alarmed\n" );
#
# Do your stuff here
system("perl", "/opt/fhem/fhem.pl", 7072, "set sinocam02 alarm")
#
}
}
sleep( 1 );
}
sudo perl zm-script.pl
Bareword "ZM_DB_NAME" not allowed while "strict subs" in use at zm-script.pl line 11.
Bareword "ZM_DB_HOST" not allowed while "strict subs" in use at zm-script.pl line 11.
Bareword "ZM_DB_USER" not allowed while "strict subs" in use at zm-script.pl line 11.
Bareword "ZM_DB_PASS" not allowed while "strict subs" in use at zm-script.pl line 11.
Execution of zm-script.pl aborted due to compilation errors.
I have already determined the bash command :
Code: Select all
perl /opt/fhem/fhem.pl 7072 "set sinocam02 alarm"
Code: Select all
system("perl", "/opt/fhem/fhem.pl", 7072, "set sinocam02 alarm");
Best regards
Holger