Users can run Python scripts through JAMS using custom Execution Methods. The custom Execution Method will differ depending on whether JAMSAgentX or JAMSAgentD is used.
If the Agent Type is SSHAgentX, then the remote machine is using JAMSAgentX, and a custom Execution Method will be created based on the SSHAgent method.
If the Agent Type is Outgoing with Platform set to Linux, then the remote machine is using JAMSAgentD, and a custom Execution Method will be created based on the UnixScript method.
In this article:
- Running Python on JAMSAgentX
- Running Python on JAMSAgentD
- Creating a Job to run Python on Agent X or Agent D
Running Python on JAMSAgentX
To run Python on JAMSAgentX, users must create a custom execution method.
- Navigate to the Execution Methods view, then click the Add button to add a new Execution Method.
- On the Add an Execution Method dialog that appears, set the Name and Description as desired.
- Choose SSHAgent as the Base Method, then click OK.
- The Execution Method Properties window will appear. Navigate to the Properties tab.
- Set the Method Type to SSHAgent.
- If SSHAgentX has a non-standard (/usr/bin/JAMSAgentX), enter the path to SSHAgentX in the Command field.
If SSHAgentX uses a standard path, ensure Command is set to JAMSAgentX. - Set Extension to py.
- On the Template tab, enter the following code:
#!/usr/bin/env python
This code tells JAMS to use Python, and will run the Python source code defined on the Job.
<<JAMS.Source>> - Save and Close the Execution Method.
Running Python on JAMSAgentD
To run Python on JAMSAgentD, users must create a custom execution method.
- Navigate to the Execution Methods view, then click the Add button to add a new Execution Method.
- On the Add an Execution Method dialog that appears, set the Name and Description as desired. While the name in this example is PythonUnix, this custom Execution Method for Agent D would work with both Unix and Linux.
- Choose UNIXScript as the Base Method, then click OK.
- The Execution Method Properties window will appear. Navigate to the Properties tab.
- Set the Method Type to Agent.
- Enter py in the Extension field.
- On the Template tab, enter the following code:
#!/usr/bin/env python
<<JAMS.Source>>
This code tells JAMS to use Python, and will run the Python source code defined on the Job. - Save and Close the Execution Method.
Creating a Job to run Python on JAMSAgentX or JAMSAgentD
Once a custom Execution Method is created for Python on either AgentX or AgentD, users may create a Job that utilizes the new Execution Method.
- Add a new Job in the JAMS Client. The Add a new JAMS Job Definition dialog will open.
- Set the Job's Folder, Name, and Description as desired.
- Set the Execution Method to the custom execution method created for Python. This example uses the AgentX version.
- Click Ok to open the Job Definition window.
- Paste or write the Python script in the Source tab.
- On the Properties tab, set the Execute As value to a user that has permissions to the relevant Agent.
- Set the Agent where the Job should execute.
- Configure other Properties and Elements as desired.
- Save and Close the Job.
Comments