Introduction

JS7 can be used to execute any scripts, executables and programs including Python® scripts.

  • Python® is a frequently used scripting language available for Linux, MacOS, Windows and other platforms.
  • This article explains how to syntactically include Python® scripts with JS7 job scripts.

Unix

  • Find examples for download (.json upload)pdScriptingPythonUnix.workflow.json
  • In order to directly add Python® script code to a JS7 shell job script the recommended approach is to use a shebang like this:

    Example how use Python script code with a shebang
    #!/usr/bin/python
     
    print("Hello")
    print("world")
  • Alternatively a Python® script can be executed from a file that has to be located by the executing Agent:

    Example how to run Python script code from a file
    #!/usr/bin/bash
    
    python hello.py

Windows

  • Find examples for download (.json upload)pdScriptingPythonWindows.workflow.json
  • In order to directly run Python® script code from a JS7 shell job script the recommended approach is to use a shebang replacement like this:

    Example how run Python® script code with a shebang replacement
    @@setlocal enabledelayedexpansion & @@findstr/v "^@@[fs].*&" "%~f0" | python.exe - & exit !errorlevel!/b&
    
    print("Hello")
    print("world")

    Explanation:

  • Alternatively a Python® script can be executed from a file that has to be located in reach of the Agent:

    Example how to run Python® script code from a single line
    python.exe hello.py