Running Python Scripts on Linux

Follow

Creating the Execution Method

In order to execute Python scripts through JAMS, first create an Execution Method to tell it how to do so.  To do this, click the Execution Methods button on the Shortcut Bar and click the +Add button within the Ribbon Bar. Name the Execution Method Python, and choose the Execution Type SSHAgent. Toggle the Checkbox to edit the Execution Method definition after creating it.

Here, under the Execution Tab, use the command JAMSAgentX or the full path to the JAMSAgentX binary on the Linux node if it is in a non-standard location. The Type should already be set as SSH Agent.

On the Template tab, add these two lines:
#!/usr/bin/env python
<<JAMS.Source>>

This tells JAMS to use Python on the Linux node and then insert the source defined in the job.


Creating the Job:
The next step is to create a Job that utilizes the Python Execution Method. Navigate to a given Folder and click the +Add button. In the job definition wizard, name the Job and optionally add a Description. When asked to pick an Execution Method, choose Python. When asked to pick a Username, select the Username of the user on the Linux Agent Node.

On the source tab, insert any Python script or program that is desired. Below is a simple script that utilizes Python functions.

#! python

# input and operator if

x = 4

if x < 0:
      x = 0
      print 'Negative changed to zero'
elif x == 0:
      print 'Zero'
elif x == 1:
      print 'Single'
else:
      print 'More'
Have more questions? Submit a request

Comments