/usr/local/bin/mail.php is only executed from the console
-
"-rwxr-xr-x" is executable for anyone, that's not the problem. But the shebang is indeed obviously wrong.
-
Fixed the shebang, and added & at the end of the email line - still does not run ???
-
Hi,
At this stage, I'm seeing the same results as you do.
The script runs fine /usr/pbi/nut-amd64/local/etc/nut/upssched-cmd.sh from the command line … but .. no mails (edit: when NUT starts upssched-cmd.sh) .Btw: change the definition of "UPSLOG".
It should read :UPSLOG=`clog /var/log/system.log | $grep ups | $tail -5`
I'm still 'fighting' with
printf "$DATUM\n$*\n\n$EMAIL_CONTENT" | /usr/local/bin/mail.php -s"UPS Alert: $EMAIL_SUBJECT" &
Which is a condensed version - command line works, from script: No.
It seems to me that /usr/local/bin/mail.php isn't even executed.Your questions were helpful to me : it seems that the battery of my UPS is in a bad shape. I have it changed it before I continu testing.
-
I've been trying this week to make this work.
I used this script:
#!/bin/sh WHOAMI=`whoami` printf "Script executed by $WHOAMI" | /usr/bin/wall logger 1223 /usr/local/bin/php -q /root/test.php logger 5678 exit 0
I know "uupc" (NUT) calls this script, because I found these in the main log:
Aug 14 12:20:20 root: 5678 Aug 14 12:20:20 root: 1223 Aug 14 12:20:20 upsmon[94982]: UPS APC-UPS@localhost on line power Aug 14 12:20:15 root: 5678 Aug 14 12:20:15 root: 1223 Aug 14 12:20:15 upsmon[94982]: UPS APC-UPS@localhost on battery
But : no trace of why this
/usr/local/bin/php -q /root/test.php
isn't executedBtw: /root/test.php
#!/usr/local/bin/php -q require_once("util.inc"); log_error("In here !!"); ?>
Btw : modo : this thread should be moved to the "Packages" forum.
-
Unfortunately I have not had any time to research any more into this myself for the past week, so thanks for your efforts. Do we believe this to be a bug, or just some misconfiguration of pfsense/nut?
I have a few things I want to test when given the opportunity:
- Can the NOTIFYCMD script call / execute any non-php file
- Does the issue remain if we set NUT to use upssched, and then call the php script via the CMDSCRIPT variable instead
- Does the issue remain if we do write the commands inline in upsmon (NOTIFYCMD = 'do stuff here')
-
I got bored trying to find a solution for this issue back in August, and I have not looked at it until today. Since August there has been a few updates of the NUT package that I silently hoped would fix my issue, but no luck. I still can't get any php script to trigger from NUT, and I am at a loss where to look next.
Where can I report this issue?
-
have you tried:
/usr/local/bin/php -f /usr/local/bin/mail.php
Rather than executing it directly?
-
Tried that, and I have lost count for how many variations I have tried. It just won't execute the php. I am now using the same script as Gertjan posted above to test, and I have the exact same results as he.
-
I have the same issue. I've never been able to get it working. There's a related feature request here.
-
Good find ryanjaeb, I had not come across that for all my searching. I am a bit disappointed by the feature not being in place, but at least it appears the issue is not on my end.
On a related topic: How do you guys then monitor the status of your UPS? I suppose I can create a separate log file, and possibly monitor that for changes to send email notifications. It would not be instant, but it could work.
-
Hi Everyone,
I'm going absolutely mad myself trying to get email notification functionality to work via the NUT package and NOTIFYCMD via upsmon.conf options.
Has anyone been able to get this to work? I too tried to use mail.php but nothing ever happens. The same command in the console works just great.
Can anyone think of another alternative method to facilitate basic email functionality though something other than mail.php if we're hitting this limitation? As in, I wonder if we could still call a script via NOTIFYCMD but instead of the script relying on mail.php, it could use some other mechanism to send the email?
This is so aggravating! Has anyone ever got NUT email functionality to work in any way-shape-form?
-
FYI- Though NUT is not yet on 2.3, using mail.php from the GUI and elsewhere appears to work on 2.3 where it did not on 2.2.x. Might be the difference in PHP versions or other changes to PHP handling, but at least from the tests I was able to run, it sent messages to me when it wouldn't otherwise.
-
hi everybody,
Can you tell me how to use mail.php under 2.3 release please. I’m looking for the syntax but without success. can you give me an example ? I try to send an email to the people who filled my php form.
Thanks in advancecheers
-
Can you tell me how to use mail.php under 2.3 release please. I’m looking for the syntax but without success. can you give me an example ? I try to send an email to the people who filled my php form.
Not likely to be usable for that. It's for basic mail from the CLI:
echo test | mail.php -s="Blah"
Start a new thread in the appropriate forum (not here) and maybe someone can help come up with a way to do what you're after.
Hosting a form like that on the firewall is not something we'd recommend, however.