Creating a Python Script
This topic provides an overview on creating a sample Python script for use with a Laserfiche Cloud Script Rule.
- Ensure that Python is installed on the remote agent host, and that the system variables have been configured to allow "python" or "python.exe" to run command-line python scripts.
- Create a .py script file or use our helper script. Inputs in the script can be accessed by:
sys.argv[1] (…) sys.argv[n]
which will return the inputs to the script in the format:
"inputName1=value1" (…) "inputNamen=valuen"
which can be parsed in your script.
Outputs from the script should be printed to the standard output in the format:
"outputName1:value1"
- The following is an example of a Python script that takes two inputs, combines them, and returns them as a single output value.
import sys
def main():
inputval1 = sys.argv[1].split("=")[1]
inputval2 = sys.argv[2].split("=")[1]
print(f"OutputValue:{inputval1} {inputval2}")
if __name__ == '__main__':
main()
Related Links
See the following Laserfiche Github page to download blank script templates for your Python scripts.