Friday, 11 April 2025

Filled under:

 const ipArray = rawIPs.split(/\s+/);

    let replicaList = [];

    let completed = 0;


    for (const ip of ipArray) {

      const command = `nslookup ${ip} | grep "name =" | sed 's/.*name = //g' | sed -r 's/\\.$//'`;


      Amelia.host.runCommand(command, function(result) {

        let hostname = "⚠️ nslookup failed";

        if (result.code === 0 && result.stdout.trim()) {

          hostname = result.stdout.trim();

        }


        replicaList.push(hostname);

        completed++;


        if (completed === ipArray.length) {

          const output = replicaList.join(" ");

          proceed({

            message: `🧭 Replica hostnames: ${output}`,

            replica_hostnames: output

          });

        }

      });

    }

0 comments:

Post a Comment