jeanmarc77 / meterN

meterN is a lightweight set of PHP/JS files that makes a " Home energy metering & monitoring " solution.
GNU General Public License v3.0
5 stars 2 forks source link

fail command for comapps execute #21

Closed sp2003 closed 6 months ago

sp2003 commented 6 months ago

I have performed a new installation of MeterN on a Debian server, but I am facing an issue with the execution of comapps. I would like to mention that the comapps have been tested and are working for several users. The version of PHP is...

deb@debian:~$ php -v
PHP 8.3.3-1+0~20240216.17+debian12~1.gbp87e37b (cli) (built: Feb 16 2024 10:32:28) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.3, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.3-1+0~20240216.17+debian12~1.gbp87e37b, Copyright (c), by Zend Technologies
deb@debian:~$

I am unable to get MeterN to execute the comapps, and this is also the case for the operating system, without specifying the full path

deb@debian:~$ reqsdm pdc_l
-bash: /usr/local/bin/reqsdm: cannot execute: required file not found

deb@debian:~$ /usr/local/bin/reqsdm pdc_l
-bash: /usr/local/bin/reqsdm: cannot execute: required file not found

deb@debian:~$ /usr/bin/reqsdm pdc_l
-bash: /usr/bin/reqsdm: cannot execute: required file not found

deb@debian:~$ php /usr/bin/reqsdm pdc_l
6(24.0*W)

deb@debian:~$ php /usr/local/bin/reqsdm pdc_l
6(24.0*W)

deb@debian:~$ php reqsdm pdc_l
Could not open input file: reqsdm

Moreover, in the debug of MeterN, I see that it is reading as if it is using bash instead of PHP.

LOG error

sh: 1: poolerproduzione: not found
sh: 1: poolerconsumi: not found
sh: 1: eflowlive: not found
sh: 1: eflowlive: not found
sh: 1: eflowlive: not found
sh: 1: reqsdm: not found

I created the symlink in both /usr/local/bin and /usr/bin.

How can I resolve this issue?

this is reqsdm.php

#!/usr/bin/php
<?php
// This script will output a meterN compatible format for the main or live command
// You'll need to setup correct permission chmod +x 
// then ln -s /var/www/comapps/reqsdm.php /usr/local/bin/reqsdm
// Request command with 'reqsdm tensione' or 'reqsdm corrente' or ......

if (isset($_SERVER['REMOTE_ADDR'])) {
    die('Direct access not permitted');
}
if (!isset($argv[1])) {
    die("Abording: no valid argument given.\n");
        } elseif ($argv[1] == 'tensione') {
            $outstr =  exec('cat /home/deb/homeassistant/shm/metern2.txt | egrep "^2_1\(" | grep "*V)"');
        } elseif ($argv[1] == 'corrente') {
            $outstr =  exec('cat /home/deb/homeassistant/shm/metern2.txt | egrep "^2_2\(" | grep "*A)"');
        } elseif ($argv[1] == 'freq') {
            $outstr =  exec('cat /home/deb/homeassistant/shm/metern2.txt | egrep "^2_3\(" | grep "*Hz)"');
        } elseif ($argv[1] == 'cospi') {
            $outstr =  exec('cat /home/deb/homeassistant/shm/metern2.txt | egrep "^2_4\(" | grep "*F)"');
//////////////////
// METERS
//////////////////
        } elseif ($argv[1] == 'pdc_l') {
            $outstr = exec('cat /home/deb/homeassistant/shm/metern6.txt | egrep "^6\(" | grep "*W)"');
        } elseif ($argv[1] == 'pdc_t') {
            $outstr = exec('cat /home/deb/homeassistant/shm/metern6.txt | egrep "^6\(" | grep "*Wh)"');

        // and so on ....
    } else {
    die("Usage: reqsdm (tensione|corrente|freq|cospi|cpu-temp|pdc_l|pdc_t)\n");
    }
echo "$outstr";
?>
deb@debian:/var/www/comapps$
total 68
-rwxr-xr-x 1 www-data www-data  2142 May  7  2018 cleanlog.sh
-rwxr-xr-x 1 www-data www-data  3707 Jan 13  2018 eflowlive.php
-rwxr-xr-x 1 www-data www-data  7347 Jan 13  2018 eflow.php
-rwxr-xr-x 1 www-data www-data 13590 Jan 13  2018 houseenergy.php
-rwxr-xr-x 1 www-data www-data    69 Nov  5  2016 index.php
-rwxr-xr-x 1 www-data www-data  2902 Jan 13  2018 pool123s.php
-rwxr-xr-x 1 www-data www-data  1383 Aug 28  2017 pooler485.sh
-rwxr-xr-x 1 www-data www-data  3763 Mar  3 16:29 poolerconsumi.php
-rwxr-xr-x 1 www-data www-data  3799 Mar  3 16:30 poolerproduzione.php
-rwxr-xr-x 1 www-data www-data  7902 Jan 13  2018 pooltot.php
-rwxr-xr-x 1 www-data www-data  1455 Mar  3 16:30 reqsdm.php
-rwxr-xr-x 1 www-data www-data  1653 Jan 13  2018 testcom.php
deb@debian:/var/www/comapps$
jeanmarc77 commented 6 months ago

https://github.com/jeanmarc77/meterN/wiki/2)-Help#i-still-cant-get-it-to-work-or-something-still-wrong