Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Internet External Program Execution

From build 3044 the development baton passed to Mark Crossley. Mark has been responsible for all the Builds since. He has made the code available on GitHub. It is Mark's hope that others will join in this development, but at the very least he welcomes your ideas for future developments (see Cumulus MX Development suggestions).

Moderator: mcrossley

Post Reply
User avatar
HansR
Posts: 5969
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bookworm
Location: Wagenborgen (NL)
Contact:

Internet External Program Execution

Post by HansR »

When I try to execute an external program on RPi Linux (for the ease of testing on the Realtime frequency) I get the following:
    Schermafbeelding 2022-12-15 090133.jpg
    which results in this output in the logfile:

    Code: Select all

    2022-12-15 09:03:28.718 Realtime[56]: Execute realtime program - utils/bin/cumulusutils.exe 
    2022-12-15 09:03:28.718 Realtime[56]: Error in realtime program - utils/bin/cumulusutils.exe . Error: ApplicationName='utils/bin/cumulusutils.exe ', CommandLine='sysinfo', CurrentDirectory='', Native error= Cannot find the specified file
    
    I have tried full path specification and I have tried mono as executable (and the rest as parameters) but it will not start.
    I assumed the CurrentDirectory would be the CumulusMX directory. Is that correct?

    The basic question is: why does it not execute?
    When I did this some years ago it did not pose any problem. Any changes?

    And as you may guess: executing it manually or from crontab is successful (in crontab I need to change directory to my CumulusMX directory before the running the executable).
    You do not have the required permissions to view the files attached to this post.
    Hans

    https://meteo-wagenborgen.nl
    CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
    User avatar
    HansR
    Posts: 5969
    Joined: Sat 20 Oct 2012 6:53 am
    Weather Station: GW1100 (WS80/WH40)
    Operating System: Raspberry OS/Bookworm
    Location: Wagenborgen (NL)
    Contact:

    Re: Internet External Program Execution

    Post by HansR »

    OK, I'll answer the question myself: removing the space at the end of the executable filename it works. :bash:
    Suggestion: trimming the line may be useful.
    This took me quite some (too much) time...
    Hans

    https://meteo-wagenborgen.nl
    CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
    User avatar
    mcrossley
    Posts: 12778
    Joined: Thu 07 Jan 2010 9:44 pm
    Weather Station: Davis VP2/WLL
    Operating System: Bullseye Lite rPi
    Location: Wilmslow, Cheshire, UK
    Contact:

    Re: Internet External Program Execution

    Post by mcrossley »

    good idea.
    NeilThomas
    Posts: 276
    Joined: Thu 11 Oct 2012 9:51 am
    Weather Station: Davis Vantage Pro2
    Operating System: Raspberry Pi 4
    Location: Gloucester
    Contact:

    Re: Internet External Program Execution

    Post by NeilThomas »

    Hi

    I'm trying to run an external program Python on my Interval time. I have confirmed that the program works in the terminal but no matter what I try in CumulusMX I get different results but no success.

    I have tried the following Interval program entries:
    python3 /home/neil/Documents/Python/mysqlInt.py &
    /home/neil/Documents/Python/mysqlInt.py

    The first returns: Traceback (most recent call last):
    File "/home/neil/Documents/Python/mysqlInt.py", line 11, in <module>
    import mariadb
    ModuleNotFoundError: No module named 'mariadb'
    and in the MXDiags error log: 2024-01-15 18:06:00.804 Interval: Error starting external program: ApplicationName='python3 /home/neil/Documents/Python/mysqlInt.py', CommandLine='', CurrentDirectory='', Native error= Cannot find the specified file

    The the second simply doesn't run and produces no errors in the log.

    The mariadb library exists in the standard library location.

    Neil
    Neil Thomas
    website: oaktreewebs.co.uk | Davis Vantage Pro II | CumulusMX, Raspberry Pi 4 | MX V4 build 4019
    User avatar
    mcrossley
    Posts: 12778
    Joined: Thu 07 Jan 2010 9:44 pm
    Weather Station: Davis VP2/WLL
    Operating System: Bullseye Lite rPi
    Location: Wilmslow, Cheshire, UK
    Contact:

    Re: Internet External Program Execution

    Post by mcrossley »

    Is MX running under the same userid as you used to test from the command line?
    User avatar
    rogerthn
    Posts: 518
    Joined: Thu 11 Apr 2013 6:31 pm
    Weather Station: Ecowitt GW1000/GW1003
    Operating System: Raspberry Pi OS bullseye aarch64
    Location: Trollhättan Sweden
    Contact:

    Re: Internet External Program Execution

    Post by rogerthn »

    NeilThomas wrote: Mon 15 Jan 2024 6:36 pm Hi

    I'm trying to run an external program Python on my Interval time. I have confirmed that the program works in the terminal but no matter what I try in CumulusMX I get different results but no success.
    ...
    Please try command below as root, assuming that CumusMX is started like sudo ...

    Code: Select all

    python3 -c "import mariadb"
    Image
    User avatar
    mcrossley
    Posts: 12778
    Joined: Thu 07 Jan 2010 9:44 pm
    Weather Station: Davis VP2/WLL
    Operating System: Bullseye Lite rPi
    Location: Wilmslow, Cheshire, UK
    Contact:

    Re: Internet External Program Execution

    Post by mcrossley »

    The second has no executable. It would work from say bash due to the association of .py files with python within bash. With MX there is no bash so you must provide the executable, and the parameters.
    NeilThomas
    Posts: 276
    Joined: Thu 11 Oct 2012 9:51 am
    Weather Station: Davis Vantage Pro2
    Operating System: Raspberry Pi 4
    Location: Gloucester
    Contact:

    Re: Internet External Program Execution

    Post by NeilThomas »

    mcrossley wrote: Mon 15 Jan 2024 6:48 pm Is MX running under the same userid as you used to test from the command line?
    The file is set to allow anyone to execute it.

    Neil
    Neil Thomas
    website: oaktreewebs.co.uk | Davis Vantage Pro II | CumulusMX, Raspberry Pi 4 | MX V4 build 4019
    User avatar
    mcrossley
    Posts: 12778
    Joined: Thu 07 Jan 2010 9:44 pm
    Weather Station: Davis VP2/WLL
    Operating System: Bullseye Lite rPi
    Location: Wilmslow, Cheshire, UK
    Contact:

    Re: Internet External Program Execution

    Post by mcrossley »

    Maybe, but does it run? I'm not familiar with python but I suspect it may need environment variables or paths setting up under the userid?
    User avatar
    rogerthn
    Posts: 518
    Joined: Thu 11 Apr 2013 6:31 pm
    Weather Station: Ecowitt GW1000/GW1003
    Operating System: Raspberry Pi OS bullseye aarch64
    Location: Trollhättan Sweden
    Contact:

    Re: Internet External Program Execution

    Post by rogerthn »

    Maybe mariadb is "installed" as below as user pi

    Code: Select all

    pip3 install mariadb
    Then it will only be pi that is aware of mariadb
    Image
    freddie
    Posts: 2481
    Joined: Wed 08 Jun 2011 11:19 am
    Weather Station: Davis Vantage Pro 2 + Ecowitt
    Operating System: GNU/Linux Ubuntu 22.04 LXC
    Location: Alcaston, Shropshire, UK
    Contact:

    Re: Internet External Program Execution

    Post by freddie »

    mcrossley wrote: Mon 15 Jan 2024 6:53 pm The second has no executable. It would work from say bash due to the association of .py files with python within bash. With MX there is no bash so you must provide the executable, and the parameters.
    There is no file association within Linux. You would need to provide the Python executable, as Mark says (and as you did in the first eg)
    Freddie
    Image
    freddie
    Posts: 2481
    Joined: Wed 08 Jun 2011 11:19 am
    Weather Station: Davis Vantage Pro 2 + Ecowitt
    Operating System: GNU/Linux Ubuntu 22.04 LXC
    Location: Alcaston, Shropshire, UK
    Contact:

    Re: Internet External Program Execution

    Post by freddie »

    mcrossley wrote: Mon 15 Jan 2024 7:14 pm Maybe, but does it run? I'm not familiar with python but I suspect it may need environment variables or paths setting up under the userid?
    Python is running just fine, it's the mariadb module that it can't find. This is very likely that the PYTHONPATH environment variable is not present when your script is executed in the MX mono environment.

    There is a well defined search path used by Python when looking for modules. I'm no Python expert, but what I would do in this situation is have MX call a bash script, and the bash script would set the PYTHONPATH environment variable and then call your python script.
    Freddie
    Image
    NeilThomas
    Posts: 276
    Joined: Thu 11 Oct 2012 9:51 am
    Weather Station: Davis Vantage Pro2
    Operating System: Raspberry Pi 4
    Location: Gloucester
    Contact:

    Re: Internet External Program Execution

    Post by NeilThomas »

    Hi all

    Issue solved - thanks for the help.

    Firstly it was down to the pythonpath variable but I solved this by installing the library module as admin so it was available to the admin user. Secondly, even though the bash script and the python program were allowed to be run by anyone, I still had to invoke python as the admin user. The bash script has to be:

    Code: Select all

    sudo python3 <python program>
    Neil
    Neil Thomas
    website: oaktreewebs.co.uk | Davis Vantage Pro II | CumulusMX, Raspberry Pi 4 | MX V4 build 4019
    Post Reply