Skip to content

Exec

The exec contrib allows you to treat any executable as though it were a pax25 app, with some limitations. The application must read and write to console (via STDIN and STDOUT), and must not require a TTY. vim, for instance, would not work, but the classic ELIZA program would.

With the Exec application, you can write a Pax25 app using whatever language you want-- you're not limited to Python.

Warning

Many executables buffer their output when connected via Pipe (the method the Exec app uses to communicate with the executables it runs.) You must ensure your intended application uses unbuffered output. If your application seems to hang forever when connecting, even if it works well over the command line, it may be affected by this issue.

To resolve this, consult the documentation for your application, or search online for how to run it(or its interpreter, if it's a script) in unbuffered mode.

Example setup and configuration

For our example, we will use an implementation of ELIZA, the classic simulated Rogerian therapist. We'll clone the repository from within our station's project directory using git:

git clone https://github.com/wadetb/eliza.git

This will create a directory named eliza in our current directory, which contains a copy of the program we'd like o run.

Now, in our main.py file where our station is set up, we need to add the exec app to the station:

import sys
from pax25.contrib.exec import Exec

...

# Add the app to the station. Be sure to change interfaces to have whatever interface you'd like to use.
station.connection.add_app(
    Exec,
    interfaces=["file"],
    settings={
        # Our example app is written in Python, since we know readers should 
        # already have it installed. sys.executable is a string that points to the
        # currently running Python interpreter path, which might be something like
        # /usr/bin/python on Linux or C:/Program Files/Python/Python.exe on
        # Windows.
        #
        # Replace it with the path to whatever executable you want to run, or the
        # path to whatever language interpreter you need.
        "path": sys.executable,

        "args": [
            # Python buffers outputs by default. However, we're pretending to give
            # the connected client terminal access (even without proper TTY
            # support) so we must instruct Python not to buffer its output.
            # Otherwise, the application may hang forever. The -u flag
            # tells the Python interpreter to run in 'unbuffered' mode.
            "-u",
            # Since we're invoking the python interpreter, we must give it the
            # path to our intended script. Here it is, assuming you cloned the
            # eliza 
            "./eliza/eliza.py"
        ],
        # In this tutorial we're assuming you cloned Eliza in your project
        # directory. However, you can change the working directory of the executed
        # application by uncommenting and customizing this line:
        # "working_directory": "/path/to/eliza/",

        # We can pass whatever environment variables we like to the target
        # executable. See the section below on Environment variables to see the
        # default ones.
        "environment": {},
    },
    # Change this to whatever helps you remember what this app does.
    application_name="Therapy",
    # This is the station clients will connect to. If this is going over the
    # air, you should omit this to auto-assign your next station SSID or else
    # manually assign avalid address you control, like MYCALL-3 or something,
    # where MYCALL is your callsign.
    station_name="ELIZA",
)

Environment variables

You may supply any environment variables you like by filling in the environment key in the Exec app settings. For convenience, a few variables are automatically set:

Key Value
PAX25_FIRST_PARTY The connecting station's Address, such as KW6FOX-3
PAX25_SECOND_PARTY The address the connecting station connected to in order to launch this app.
PAX25_INTERFACE_NAME The name of the interface used to connect to the app.
PAX25_INTERFACE_TYPE The type of the interface used to connect, such as tcporfile.