Page 1 of 1

Runnining a script from filter to trigger serial port error

Posted: Sat Feb 09, 2008 12:11 pm
by danielareas
Hi,

Can someone help me solve this problem I having to run the script listed below, from the command line on the filter window. When I try to run from the terminal, it runs perfectly, but when I try to run it from the filter command line,I get the folowing message from zmfilter.log:

02/09/08 09:50:23.503750 zmfilter[8098].DBG [Checking event 1213]
02/09/08 09:50:23.503902 zmfilter[8098].INF [Executing '/usr/bin/zmserial.pl 1/1213']
02/09/08 09:50:24.433664 zmfilter[8098].DBG [Output: ]
02/09/08 09:50:24.434049 zmfilter[8098].ERR [Command '/usr/bin/zmserial.pl 1/1213' exited with status: 9]


SCRIPT:

#!/usr/bin/perl -w
use strict;
use bytes;
use constant DBG_ID => "zmserial"; # Tag that appears in debug to identify source
use constant DBG_LEVEL => 1; # 0 is errors, warnings and info only, > 0 for debug
use ZoneMinder::Trigger::Connection;
use ZoneMinder::Trigger::Channel::Serial;

my @connections;

push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan4", channel=>ZoneMinder::Trigger::Channel::Serial->new( path=>'/dev/ttyS0' ), mode=>"rw" ) );

use ZoneMinder;
use DBI;
use Data::Dumper;
use POSIX qw( EINTR );
use Time::HiRes qw( usleep );

$| = 1;

$ENV{PATH} = '/bin:/usr/bin';
$ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};

zmDbgInit( DBG_ID, level=>DBG_LEVEL );
zmDbgSetSignal();

foreach my $connection ( @connections )
{

$connection->open();
sleep (5);
}


Thank you,

Daniel Areas

Posted: Sun Feb 10, 2008 6:43 pm
by zoneminder
I suspect this will turn out to be a permissions problem. It's worth checking zmpkg.log znd zmdc.log as well as your httpd error log as sometimes errors seem to get propagated up and not appear in the most obvious log. You could also try running your script direct as the web user via su or sudo to see what happens.

Posted: Sat Feb 23, 2008 1:04 pm
by danielareas
Hi Phil,

Thank you for your reply, I checked all the logs you listed, but I found no errors. When I run the script as a web user, it runs perfectly. The problem occurs when I try to run it from the filter. Do you have any clue of what is happening?

thank you,

Daniel Areas

Posted: Sat Feb 23, 2008 1:08 pm
by danielareas
Hi Phil,

I forgot to ask what is the Status 9 error.

Thanks,

Daniel Brito

Posted: Sat Feb 23, 2008 6:55 pm
by cordel
This are actualy difined in linux, a good litle read as well:
http://linux.about.com/od/commands/l/blcmdl7_signal.htm

Script for Serial Port

Posted: Mon Mar 10, 2008 1:21 pm
by danielareas
Thank you for your reply, but I need to know why the error occurs in the command to open the serial port when the script is called by the filter. When I run the same script in the terminal window with the user 'sudo', the serial port is opened and works fine, with the user ´home´, it shows the following error: "Can't open log file '/tmp/zmserial.log': Permission denied at /usr/share/perl5/ZoneMinder/Debug.pm line 279", after that, I grant the permission: "sudo chmod 777 /usr/bin/zmserial.log" e "sudo chmod 777 /usr/share/perl5/ZoneMinder/*.*" and the script runs fine. I´ve checked the logs zmpkg.log and zmdc.log like Phil suggested and didn´t find any errors. I´m using version 1.22.3-10 packed by Peter Howard running on UBUNTU 6.06 Dapper. Any suggestions will be welcome.

Daniel Areas