iagctl run service python-script
iagctl run service python-script
Run a Python script service.
The iagctl run service python-script command executes a Python script service and displays the resulting stdout, stderr, return code, and execution time information.
Syntax
Usage notes
Runtime arguments
Use the --set flag to pass CLI arguments to the Python script using key=value syntax. If you defined a decorator during service creation, IAG validates all --set values against it before passing them to the script.
View accepted inputs
Use the --use flag with the service name to display information about the inputs a service accepts:
How IAG passes arguments to scripts
When you use the --set flag, IAG passes each value to the script in --key=value format. For example, this command:
Causes IAG to run the following command in the virtual environment:
Your script needs to parse these arguments using Python’s argparse.ArgumentParser module. The following example shows how to handle both simple string values and JSON inputs:
Examples
Run a Python script service
Run a Python script service with arguments
The following example passes device and commands arguments to the script.