Change execute command stdout double quote added behavior

Hi, since N8N does not support SNMP querry, I’m using execute command with the linux snmp tool and some awk/sed/tr fu to manipulate the data output. My problem is that I getting multiple serial number of the devices I query and should logically return it as an array but I can’t format the output to result in a valid json syntax.

My output will be similar to this

oid.1 = "serial1"
oid.2 = "serial2"
oid.3 = "serial3"

Maybe it’s not the best way to do this in N8N but I used linux tools (awk, sed, tr, etc.) to format it in a standard array output like this
["serial1", "serial2", serial3"]

But the execute command node will add a double quote before and after the array like following

[
  {
    "exitCode": 
    0,
    "stderr": 
    "",
    "stdout": 
    "["serial1", "serial2", "serial3"]"
  }
]

so, standard output isn’t a valid json syntax. Is their any way that the execute shell node will not add those double quote before and after the stdout data like in the following ?

[
  {
    "exitCode": 
    0,
    "stderr": 
    "",
    "stdout": 
    ["serial1", "serial2", "serial3"]
  }
]

Else, is their a better way to handle modifying the data in N8N to format it in a json valid output ?

Here is the workflow

thanks

Information on n8n setup

  • **n8n version: 1.27.2
  • **Database : SQLite
  • **n8n EXECUTIONS_PROCESS setting (default: own, main): manual
  • **Running n8n via npm (docker don’t include SNMP)
  • **Operating system: debian 12 with nodejs 18.x (official ubuntu/debian repo)

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Solved. When I was copying the json from the output section and pasting it in a parser, the json syntax had an error but when I query it with postman, the return was not the same and the syntax is show in postman was ok.

P.S. I can’t figure out how to change the title to mark it solved else I would have done it.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.