Parsing Data from Execute Command node / stdout

Hello.
I’m using the Execute Command node to return a filtered process list.
I’ve tried formatting it a few different ways, to possibly use it in a workflow, but am still struggling.
tasklist /svc /fi “pid eq 17704” /FO list
tasklist /svc /fi “pid eq 17704” /FO csv

The result comes back like this:

[
  {
    "exitCode": 0,
    "stderr": "",
    "stdout": "Image Name: chrome.exe PID: 17704 Services: N/A"
  }
]

or like this (when using /FO csv)

[
  {
    "exitCode": 0,
    "stderr": "",
    "stdout": ""Image Name","PID","Services" "chrome.exe","17704","N/A""
  }
]

I’ve stuggled correctly making the function to parse the stdout value to json and use that in a workflow. Could someone please assist?

My intention, is to use a cron node to repeatedly make this call to check on the existence of a process, and create an alert if it does not exist.

Hi @diskin, so instead of having the entire String in the `stdout field you’d like to have separate fields for image name, PID and services?

The CSV output looks pretty great for that. If you convert stdout into binary data using the Move Binary Data node and then have the Spreadsheet File node read it, this is what you get (also works using the /fi option of course):

Here’s my example workflow which you can simply copy and paste into your n8n canvas:

Example Workflow

Perfect - Thank you so much!

1 Like