The Function node gives me 3 hostnames, how to loop easily to exec-command in each?

All is in the title :slight_smile:

Sadly still more information needed as there is literally an unlimited amount o ways how this 3 hostnames are “given”. How does the output-data of the node look like?

You are right jan
end of Function node :

items[0].json.myHosts = myHosts;
return items;

myHosts is type [:string]

Then it could look like this:

Yes, that works jan, so a single exec can launch several command sequentially or in parallel
But here I need to analyse the command result (stdout) on each host or partially, depending of previous host’s result, am I clear ?
In fact, a function where I could fork (promise for ex) is fine, but the Function node is not made for that I think … Or, give to Exec command a very long command with if, else etc… and get the final output for the nex node
Am I right ? An other way ?

Yes, that works jan, so a single exec can launch several command sequentially or in parallel

Yes

But here I need to analyse the command result (stdout) on each host or partially, depending of previous host’s result, am I clear ?

Sure, if you have to do that you can do that.

In fact, a function where I could fork (promise for ex) is fine, but the Function node is not made for that I think … Or, give to Exec command a very long command with if, else etc… and get the final output for the nex node

Not sure I understand. But it is possible to return a promise in the Function-Node. Apart from that, can you do literally anything in the Function-Node. You can even use any module that is installed as long as you configured n8n accordingly:

If the code exists … jan do you have an example of a Function node usind the Exec-command node ?

That is not possible to use one node inside of another. What is possible is to use “child_process” in the Function-Node. Here the code of the Execute Command-Node:
https://github.com/n8n-io/n8n/blob/master/packages/nodes-base/nodes/ExecuteCommand.node.ts

or even simpler here some examples on stackoverflow:

Ok thanks jan!