• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

/usr/local/bin/mail.php is only executed from the console

Scheduled Pinned Locked Moved pfSense Packages
20 Posts 7 Posters 5.2k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L
    Lanes
    last edited by Aug 8, 2015, 4:40 PM

    Fixed the shebang, and added & at the end of the email line - still does not run  ???

    1 Reply Last reply Reply Quote 0
    • G
      Gertjan
      last edited by Aug 10, 2015, 2:03 PM Aug 10, 2015, 9:17 AM

      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.

      No "help me" PM's please. Use the forum, the community will thank you.
      Edit : and where are the logs ??

      1 Reply Last reply Reply Quote 0
      • G
        Gertjan
        last edited by Aug 14, 2015, 12:36 PM

        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 executed

        Btw: /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.

        No "help me" PM's please. Use the forum, the community will thank you.
        Edit : and where are the logs ??

        1 Reply Last reply Reply Quote 0
        • L
          Lanes
          last edited by Aug 14, 2015, 9:08 PM

          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:

          1. Can the NOTIFYCMD script call / execute any non-php file
          2. Does the issue remain if we set NUT to use upssched, and then call the php script via the CMDSCRIPT variable instead
          3. Does the issue remain if we do write the commands inline in upsmon (NOTIFYCMD = 'do stuff here')
          1 Reply Last reply Reply Quote 0
          • L
            Lanes
            last edited by Nov 5, 2015, 9:24 PM

            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?

            1 Reply Last reply Reply Quote 0
            • J
              jimp Rebel Alliance Developer Netgate
              last edited by Nov 9, 2015, 2:53 PM

              have you tried:

              /usr/local/bin/php -f /usr/local/bin/mail.php
              

              Rather than executing it directly?

              Remember: Upvote with the šŸ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

              Need help fast? Netgate Global Support!

              Do not Chat/PM for help!

              1 Reply Last reply Reply Quote 0
              • L
                Lanes
                last edited by Nov 9, 2015, 8:43 PM

                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.

                1 Reply Last reply Reply Quote 0
                • R
                  ryan87
                  last edited by Nov 19, 2015, 3:48 PM

                  I have the same issue.  I've never been able to get it working.  There's a related feature request here.

                  1 Reply Last reply Reply Quote 0
                  • L
                    Lanes
                    last edited by Nov 21, 2015, 8:56 AM

                    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.

                    1 Reply Last reply Reply Quote 0
                    • L
                      larathydo
                      last edited by Feb 2, 2016, 1:52 AM

                      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?

                      1 Reply Last reply Reply Quote 0
                      • J
                        jimp Rebel Alliance Developer Netgate
                        last edited by Feb 11, 2016, 7:33 PM

                        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.

                        Remember: Upvote with the šŸ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

                        Need help fast? Netgate Global Support!

                        Do not Chat/PM for help!

                        1 Reply Last reply Reply Quote 0
                        • C
                          Carltonson-sky
                          last edited by Mar 17, 2016, 12:16 PM

                          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 advance

                          cheers

                          1 Reply Last reply Reply Quote 0
                          • J
                            jimp Rebel Alliance Developer Netgate
                            last edited by Mar 18, 2016, 3:16 PM

                            @Carltonson-sky:

                            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.

                            Remember: Upvote with the šŸ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

                            Need help fast? Netgate Global Support!

                            Do not Chat/PM for help!

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post
                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                              This community forum collects and processes your personal information.
                              consent.not_received