2
私はssh-exec npmを使用しています。リモートのsshコマンドの結果を取得し、解析して配列に格納したいと考えています。代わりにstdoutにパイプされているので、変数に取り込む方法がわかりません。stdoutから読む
function GetRemoteLinuxIp(hostAddress) {
console.log(hostAddress);
exec("ifconfig -a | tr -s ' ' | awk -F'[: ]' ' {if (/^[a-z]/) printf $1 \" \"} {if (/inet addr:/) print $4 }' ", {
user: 'user',
host: hostAddress,
password: 'password'
}).pipe(process.stdout)
};
出力は
enp0s3 192.168.1.8
enp0s3 192.168.1.9