Am Freitag 01 Dezember 2006 16:29 schrieb David Nolan: > You said "no absolute path specified", did you mean no non-absolute > paths specified? i.e. if your script runs a program named foobar from > /usr/local/bin it should be calling it as /usr/local/bin/foobar, not > assuming /usr/local/bin is in $PATH. (Alternatively you can set $PATH > in your script...)
I was referring to the inclusion of alert scripts within the mon config file; should have called it "relative" though. > Try adding some debugging code in your script. i.e. if its perl add > something like: > open(LOG, ">/tmp/alertlog"); > ... > print LOG "got to step XXX\n"; > ... > print LOG "got to step YYY\n"; Tried it and was unsuccessful. > When testing your alert are you also passing the other options that > Mon sets when calling an alert? i.e. '-g group -s service -h "list of > hosts here"', etc... (See the Mon man page for full documentation.) No, I haven't, assuming it wasn't necessary. I'll give it a try. > What user do you run mon as? Have you tested su'ing to that user and > running the script? -rwxr-xr-x 1 root root 111458 2003-05-28 10:25 mon > Can you post a copy of your script for us to look at? (without any > SMS numbers, of course...) Sure, here you go: #!/usr/bin/perl use strict; use warnings; use Device::Modem; use Getopt::Std; my ($anser, %opts, @recipients, $summary); my ($modem, $msg); my $device = '/dev/ttyS1'; my $pin = 2130; my $sleep = 5; parse_args(); #check_len_msg(); main(); sub main { foreach my $recipient (@recipients) { init(); set_opts(); send_cmds($recipient); disconnect(); } } sub parse_args { getopts('S:v', \%opts); @recipients = @ARGV; usage() unless defined $opts{S}; #$msg = $opts{S}; $summary=<STDIN>; chomp($summary); $msg = { local $/; <STDIN> }; } sub usage { print <<EOT; $0 [-Sv] recipient(s) -S\tsend message -v\tverbose EOT exit(1); } sub check_len_msg { die "message exceeds size of 160 character!\n" if length($msg) > 160; } sub init { $modem = Device::Modem->new(port => $device); if ($modem->connect(baudrate => 9600)) { print "Connecting...\n" if $opts{v}; } else { print "Sorry, no connection with serial port!\n"; } } sub set_opts { $modem->is_active(); $modem->verbose(1); } sub send_cmds { my $recipient = shift; $modem->atsend("AT\r"); print $modem->answer()."\n" if $opts{v}; $modem->atsend("AT+CSCS=GSM\r"); print $modem->answer()."\n" if $opts{v}; $modem->atsend("AT+CPIN=?\r"); print $modem->answer()."\n" if $opts{v}; $modem->atsend("AT+CPIN?\r"); my $answer = $modem->answer()."\n"; $answer =~ s/(?:\+CPIN:\s\w+)\s*(.*)/$1/; print $answer if $opts{v}; $modem->atsend("AT+CMGC=?\r"); print $modem->answer()."\n" if $opts{v}; $modem->atsend("AT+CMGF=1\r"); print $modem->answer()."\n" if $opts{v}; my @msgs; while (length($msg) > 160) { my $msg_chunk = substr($msg, 0, 160); push @msgs, $msg_chunk; $msg = substr($msg, 160, length($msg)); } push @msgs, $msg; foreach my $msg (@msgs) { sleep($sleep); $modem->atsend("AT+CMGS=$recipient\r"); sleep($sleep); $modem->atsend("$msg\cz"); } } sub disconnect { $modem->disconnect(); } > -David Regards, Steven _______________________________________________ mon mailing list mon@linux.kernel.org http://linux.kernel.org/mailman/listinfo/mon