bBox_Python3Run( mode; script {; text; param1; ...} )

Parameters:
   mode:
      0 = convert both input and output line endings, wait for output
      1 = skip conversion of carriage returns (the FileMaker end-of-line marker) to new lines
      2 = skip translation of new lines in shell output to carriage returns
      3 = don't translate input or ouput line endings
      4 = run asynchronously (don't wait for output)
      16 = use alternate Python command path
      32 = combine Python stdout and stderr output
   script: text to be compiled into bytecode
   param1…: optional parameters for the python3 command

Result:
   text sent to stdout

Error:
   bBox_LastError ("posix")

Script Step:
   bBox Python3 Run [ Mode: Script: Input: Param1: Param2: Param3: ]

––––––––––

First appeared in: 0.90

Examples in demo file: 6

Compatibility:   Client, macOS, Server, Ubuntu, WebDirect, WPE

––––––––––

On macOS, this requires the installation of Python Software Foundation's version of Python. On Ubuntu you would typically use apt-get to install it. There is is also an option to use an executable at an alternate path, which may require creating a symlink to the python3 binary you wish to use.

The default Python command paths are:

The alternate paths are:

Python modules installed on Linux may not be in the default path. If needed, add the following before your import statement:

import sys
sys.path.append('/usr/local/lib/python3.10/dist-packages')   # use python3.9 for Ubuntu 20

Use bBoxy_LastError (-3) to get error result. While testing, using a mode of 32 is recommended. This will cause stderr output from Python to be returned as the script step/function result. Otherwise, messages about things like Python syntax errors will be lost, and you will only have the error message returned by bBox_LastError.

These calls are thread safe, so you can safely have multiple Python 3 scripts running at the same time. The script step does not support the Python fm module however — for fm methods you’ll need to use the bBox_PythonExecute or bBox_PythonEval functions.

You can pass parameters to Python using the function's optional param parameters. Then in Python, use its sys.argv variable to extract these as needed.

––––––––––

bBox Functions

bBox Wiki