I want to run an awk command for a file in remote server. I connect with ssh and I run the following command:
cat /orch/servers | grep "+sNo+" | awk '{print $1}'
Type of this command's output is string. But I want to this output be array. The javascript code is below:
vmIDListCmd = "cat /orch/servers | grep "+sNo+" | awk '{print $1}'"
try {
session = new SSHSession(hostName, username, 22);
session.connectWithPasswordOrIdentity(passwordAuthentication, password);
vmIDList = session.executeCommand(vmIDListCmd, true);
}
catch (e) {
throw "Unable to execute command: " + e;
}
finally {
if (session) {
session.disconnect();
}
System.log(vmIDList);
}
Output:
vm1 vm2 vm3 vm4
vmIDList variable (the output) is a string. I want to this variable be an array.