Running Python on Linux or Unix with JAMS Agent D and Agent X

Follow

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

To run Python on JAMSAgentX, users must create a custom execution method. 

  1. Navigate to the Execution Methods view, then click the Add button to add a new Execution Method.
    AddExecutionMethodButton.png
  2. On the Add an Execution Method dialog that appears, set the Name and Description as desired.
  3. Choose SSHAgent as the Base Method, then click OK.
    PythonAgentXEM.png
  4. The Execution Method Properties window will appear. Navigate to the Properties tab.
  5. Set the Method Type to SSHAgent.
  6. 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.
  7. Set Extension to py.
    PythonAgentXEMPropertiesTab.png
  8. 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.
    PythonAgentXEMTemplate.png
  9. Save and Close the Execution Method.

 

Back to Top


 

Running Python on JAMSAgentD

To run Python on JAMSAgentD, users must create a custom execution method.

  1. Navigate to the Execution Methods view, then click the Add button to add a new Execution Method.
    AddExecutionMethodButton.png
  2. 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.
  3. Choose UNIXScript as the Base Method, then click OK.
    PythonAgentDEM.png
  4. The Execution Method Properties window will appear. Navigate to the Properties tab.
  5. Set the Method Type to Agent.
  6. Enter py in the Extension field.
    PythonUnixProperties.png
  7. 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.
    PythonAgentDEMTemplate.png

  8. Save and Close the Execution Method.

 

Back to Top


 

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.

  1. Add a new Job in the JAMS Client. The Add a new JAMS Job Definition dialog will open.
  2. Set the Job's Folder, Name, and Description as desired.
  3. Set the Execution Method to the custom execution method created for Python. This example uses the AgentX version.
    PythonJobDefinition.png
  4. Click Ok to open the Job Definition window.
  5. Paste or write the Python script in the Source tab.
    PythonJobSource.png
  6. On the Properties tab, set the Execute As value to a user that has permissions to the relevant Agent.
  7. Set the Agent where the Job should execute.
    PythonJobProperties.png
  8. Configure other Properties and Elements as desired.
  9. Save and Close the Job.

 

Back to Top

Have more questions? Submit a request

Comments