Describe the problem/error/question
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.
error: unknown command: cd\npp0.3221370504 184.108.40.206 [email protected] default:default \npp0.3221370506 220.127.116.11 [email protected] default:default \npp0.3221370520 18.104.22.168 [email protected] default:default \npp0.3221370524 22.214.171.124 [email protected] default:default \npp0.3221370539 126.96.36.199 [email protected] default:default
Please share your workflow
Share the output returned by the last node
error: unknown command: cd\npp0.3221370891 188.8.131.52 [email protected] default:default \npp0.3221370893 184.108.40.206 [email protected] default:default \npp0.3221370895 220.127.116.11 [email protected] default:default \npp0.3221370896 18.104.22.168 [email protected] default:default \npp0.3221370899 22.214.171.124 [email protected] default:default \n---(more 60%)---
What we would like to extract:
With the above desired output, the first portion before the @ sign is a variable length string between 6 and 12 digits long.
Information on your n8n setup
n8n version: 0.222.3
Database (default: SQLite): SQLite
n8n EXECUTIONS_PROCESS setting (default: own, main): [Unsure]
Running n8n via (Docker, npm, n8n cloud, desktop app): npm
Operating system: Ubuntu 22.04 LTS
Hi @Robert_Fitzgerald, welcome to the community!
Based on the example you have provided it sounds like you can:
- Split your string by line
- Remove the line starting with
- 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:
Hope this helps!
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:
Thanks Tom, really appreciate you taking the time to help me
"error: unknown command: cd pp0.3221373588 126.96.36.199 [email protected] default:default pp0.3221373590 188.8.131.52 [email protected] default:default pp0.3221373592 184.108.40.206 [email protected] default:default pp0.3221373606 220.127.116.11 [email protected] default:default pp0.3221373608 18.104.22.168 [email protected] default:default ---(more 100%)---",
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:
You should get your JSON payload with indentation when copying it as described above.
Sorry Tom, it shows me 3 options for copying on that button, the last response I used Copy Item Path, here are the others:
Copy Selection and Copy Parameter Path didn’t seem to do anything at all (even with text selected), is there another way to achieve it?
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.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.