- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 01:01 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 08:01 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 05:08 PM
Hi @alexgg57
Yes, I think you can run a Python script on a MID Server that is installed on a Linux OS.
As MID Servers are designed to execute various scripts and tasks, including Python scripts, on the host machine where they are installed, whether it's Windows or Linux.
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 07:38 AM
Thanks Tushar!
So how I can call PY script from a flow designer/action? I heard the Linux MID does not have a Powershell capabilities...
Am I wrong?
Thanks,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 12:25 PM
Hello,
If anyone is using Python in MID and call it from FlowDesigner/Action?
I really have specific questions, but not sure if anybody uses...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 12:08 AM - edited 07-30-2024 12:14 AM
Hi,
Yes, I am. I'm running MID server on linux. Using this to update knowledge article content with current information on local network devices.
On the MID server, I've setup a venv environment.
Then, I just create a bash script on the mid server using MID Server Script Files. Needed to login to MID server and then "chmod +x <script file name>". I've set the Parent to "SSH".
Filename:test.sh
#!/bin/bash
cd /opt/servicenow/mid/venv/test ## change this to the directory of ven
source bin/activate
result =$(python test.py) # python script to execute
echo $result
On the FlowDesigner, I just create a flow with "Create Record" step. Executing this from scheduled job.
Action: Create Record
Table: Queue [ecc_queue]
Fields:
Agent : mid.server.<mid server name>
Topic: Command
Queue: output
State: ready
Name: scripts/SSH/test.sh
Payload:<parameters><parameter name="skip_sensor" value="true"/></parameters>