I need to extract a list of connected subscribers from a Juniper network router via SSH. We would also like to eliminate the “cd /” from the executed command as it is not supported on this device.
Based on the example you have provided it sounds like you can:
Split your string by line
Remove the line starting with error:
Split each line on the whitespaces and keep the third result for each line
This is a bit tricky but possible. Here’s an example workflow:
In this example I’ve kept the respective input line for comparison, but if you want to get rid of it simply flip the “Keep Only Set” toggle on the node:
Thanks so much for the great solution, I copied/pasted from your example however I’m struggling to get the last node to work correctly with keeping the 3rd item, are you able to see what’s wrong? It should be identical to yours, although I did have to re-create the “Split into separate items” as it showed up unrecognised when I pasted it.
Here’s what I have now:
This is the output showing my side from the above flow:
I suspect this could be related to the exact data structure you are having. Can you confirm the exact JSON output your SSH node returns? Please make sure to copy it like so to not loose any formatting:
Hi @Robert_Fitzgerald, this looks like you might have selected your JSON code and then copied it instead of using that Copy button.
Could you try copying this data one more time? Make sure you use the button highlighted in my screenshot, it’ll only appear once you hover over the actual JSON payload:
I’m so sorry for this, this UI has changed a bit recently. On your version of n8n you’d need to click on the first line of your JSON data here, then use the Copy Selection option, I’ve explained this over here with another screenshot.
Ultimately this would come down to finding a split logic that works for your exact data structure.