Need a Python script to run in MID server (Linux OS)

alexgg57
Tera Expert

Hello Team,

 

I know, if MID server is on Windows OS, there is a possibility to run a Pyton script via PowerShell Flow Action.

However, I am interesting if we can call a Python in the MID if it's on Linux OS?

Any thoughts/ideas?

Thanks,

Alex.

 

1 ACCEPTED SOLUTION

DYCM
Mega Sage

Hi @alexgg57 ,

To execute python on MID Server, you can generate the ECC Queue record to invoke python script using the following code snippet:

 

var agent = "mid.server.MID_Server";
var eccQueue = new GlideRecord('ecc_queue');
eccQueue.initialize();
eccQueue.agent = agent; // replace with your MID server name
eccQueue.topic = 'Command';
eccQueue.queue = 'output'; // for an output record
eccQueue.state = 'ready'; // state must be 'ready'
// specify parameters in the payload
// skip sensor: skip_sensor
eccQueue.payload = '<parameters><parameter name="name" value="<path_to_your_python.exe> <path_to_your_python_file.py>"/><parameter name="skip_sensor" value="true"/></parameters>';


var sysId = eccQueue.insert(); 

 

Please remember to install Python on your Linux server, and specify the correct path in above code.

View solution in original post

7 REPLIES 7

joshuastanley
Tera Expert

You will have to activate the plugin Integrationhub with standard package. That will provide the spoke for powershell and SSH enablement.

DYCM
Mega Sage

Hi @alexgg57 ,

To execute python on MID Server, you can generate the ECC Queue record to invoke python script using the following code snippet:

 

var agent = "mid.server.MID_Server";
var eccQueue = new GlideRecord('ecc_queue');
eccQueue.initialize();
eccQueue.agent = agent; // replace with your MID server name
eccQueue.topic = 'Command';
eccQueue.queue = 'output'; // for an output record
eccQueue.state = 'ready'; // state must be 'ready'
// specify parameters in the payload
// skip sensor: skip_sensor
eccQueue.payload = '<parameters><parameter name="name" value="<path_to_your_python.exe> <path_to_your_python_file.py>"/><parameter name="skip_sensor" value="true"/></parameters>';


var sysId = eccQueue.insert(); 

 

Please remember to install Python on your Linux server, and specify the correct path in above code.

alexgg57
Tera Expert

Thank you!