Running Python Scripts
JAMS provides three Execution Methods to let you easily run Python scripts. Each Execution Method is specific to the supported operating system. You will need to choose the appropriate one based on your environment.
The following Execution Methods are available:
- PythonSSH – Execute Python code on an SSH Agent.
- PythonUnix – Execute Python code on a Unix Agent.
- PythonWindows – Execute Python code on a Windows Agent or JAMS Scheduler.
Running Python Scripts on an SSH Agent
JAMS has an Execution Method to let you run Python code on an SSH Agent. With this Execution Method, you can copy and paste your code into the Job and have JAMS run it.
Before you Begin
- Ensure you have JAMS AgentX installed.
- Ensure Python is installed on the JAMS Agent.
- Ensure you have a JAMS Credential created to run the Job in JAMS. This Credential should have permissions to the relevant Agent. See Credentials for more information.
Using the PythonSSH Execution Method
- Click Execution from the main menu.
- Click Execution Methods.
- Click the PythonSSH Execution Method to review its properties.
- Click the Template tab.
- Enter the location of the Python executable on the Agent. The default value of this is:
#!/usr/bin/env python
<<JAMS.Source>>
- Click Save.
- Click Jobs from the main menu.
- In the Folder Navigator, select a Folder where the Job will be saved.
- Click Add to add a new Job.
- In the Job Name field, enter a name for the Job.
- In the Execution Method field, select PythonSSH.
- Click Save and Continue to Edit.
- On the Source tab, paste your Python code.
- Click the Schedules tab.
- As needed, schedule when the Job will run.
- Click the Properties tab.
- In the Agent field, select the JAMS Agent that will run the Job.
- In the Execute As field, select the JAMS Credential that will be used to run the Job.
- Click Save.
Running Python Scripts on a Unix Agent
JAMS has an Execution Method to let you run Python code in a Unix environment. With this Execution Method, you can copy and paste your code into the Job and have JAMS run it.
Before you Begin
- Ensure you have a JAMS AgentD installed. See JAMS AgentD for Linux/Unix for more information.
- Ensure Python is installed on the JAMS Agent.
- Ensure you have a JAMS Credential created to run the Job in JAMS. This credential should have permissions to the relevant Agent. See Credentials for more information.
Using the PythonUnix Execution Method
- Click Execution from the main menu.
- Click Execution Methods.
- Click the PythonUnix Execution Method to review its properties.
- Click the Template tab.
- Enter the location of the Python executable on the Agent. The default value of this is:
#!/usr/bin/env python
<<JAMS.Source>>
- Click Save.
- Click Jobs from the main menu.
- In the Folder Navigator, select a Folder where the Job will be saved.
- Click Add to add a new Job.
- In the Job Name field, enter a name for the Job.
- In the Execution Method field, select PythonUnix.
- Click Save and Continue to Edit.
- On the Source tab, paste your Python code.
- Click the Schedules tab.
- As needed, schedule when the Job will run.
- Click the Properties tab.
- In the Agent field, select the JAMS Agent that will run the Job.
- In the Execute As field, select the JAMS Credential that will be used to run the Job.
- Click Save.
Running Python Scripts on Windows Agent
JAMS has an Execution Method to let you run Python code in a Windows environment. With this Execution Method, you can copy and paste your code into the Job and have JAMS run it.
You can also have your Python code in a separate .PY file and reference it within a JAMS Job by using the Command Execution Method. Both Execution Methods are described in the sections below.
Before you Begin
- Ensure you have a JAMS Windows Agent installed. See JAMS Agent for Windows for more information.
- Ensure Python (Python.exe) is installed on the JAMS Windows Agent or JAMS Scheduler.
- Ensure you have a JAMS Credential created to run the Job in JAMS.
Using the PythonWindows Execution Method
- Click Execution from the main menu.
- Click Execution Methods.
- Click the PythonWindows Execution Method to review its properties.
- Click the Properties tab.
- From the list of properties, go to the Command property.
- Update or verify the property that lists the location of the Python.exe on your JAMS Windows Agent or JAMS Scheduler. It will look similar to the following: C:\Users\MyAccount\AppData\Local\Programs\Python\Python314\python.exe "{0}". Ensure the "{0}" is included.
- Click Save.
- Click Jobs from the main menu.
- In the Folder Navigator, select a Folder where the Job will be saved.
- Click Add to add a new Job.
- In the Job Name field, enter a name for the Job.
- In the Execution Method field, select PythonWindows.
- Click Save and Continue to Edit.
- On the Source tab, paste your Python code.
- Click the Schedules tab.
- As needed, schedule when the Job will run.
- Click the Properties tab.
- In the Agent field, select the JAMS Agent that will run the Job. Leave it blank to have it run on the JAMS Scheduler.
- In the Execute As field, select the JAMS Credential that will be used to run the Job.
- Click Save.
Using the Command Execution Method to run Python Scripts on Windows
- Click Jobs from the main menu.
- In the Folder Navigator, select a Folder where the Job will be saved.
- Click Add to add a new Job.
- In the Job Name field, enter a name for the Job.
- In the Execution Method field, select Command.
- Click Save and Continue to Edit.
- On the Source tab, paste your Python code. You will need to reference the location of the python.exe and .py files. It may look similar to the following:
c:\Users\MyAccount\AppData\Local\Programs\Python\Python314\python.exe c:\hello.py
- Click the Schedules tab.
- As needed, schedule when the Job will run.
- Click the Properties tab.
- In the Agent field, select the JAMS Agent that will run the Job. Leave it blank to have it run on the JAMS Scheduler.
- In the Execute As field, select the JAMS Credential that will be used to run the Job.
- Click Save.