node2sのsimple-sshモジュール.exec()
を使用してhive -e
コマンドを実行できません。
一重引用符に問題があると思われます。'
または"
です。私はどのような引用をどの順序に入れるのか分かりません。私はたくさんの組み合わせを試みましたが、どれも働いていませんでした。simple-ssh npmモジュールの.exec()メソッドを使用して "hive -e 'select *を実行できません
var runSSH(obj){
var ssh = new SSH({
host: remote1,
user: 'root',
timeout: 1500000,
key: require('fs').readFileSync("C:/Users/Aiman/Desktop/hRep_prv"),
agent: process.env.SSH_AUTH_SOCK,
agentForward: true
});
ssh.exec('timeout 900 ssh -i /root/rsaPrvtKeyPath/to/remoteHost2 '+remoteHost2+' \'for i in '+remote3+' '+remote4+'; do clush -w ${i} "hive -e \'select * from table_name limit 3;\'" done\' ',{
out: function(stdout) {
devHive_check += stdout;
obj.devHive_check = devHive_check;
console.log(stdout);
}
}) //-->not executing
.exec('timeout 300 ssh -i /root/rsaPrvtKeyPath/to/remoteHost2 '+remoteHost2+' \'for i in '+remote3+' '+remote4+'; do clush -w ${i} "ps -ef | grep HiveServer2"; done;\' ',{
out: function(stdout) {
devHS2_check += stdout;
obj.devHS2_check = devHS2_check;
console.log(stdout);
}
})//-->running fine
.exec('echo "parse and save"',{
out: function(){
parseData(obj);
ssh.end();
}
}).start(); //-->running fine
}
私は(ハイブが実行されている、私はHive
をチェックするためにremoteHost2へssh
をやって、(細かいrunnigされている)シェルスクリプトのカップルを実行している、remoteHost1にログインしています:ここで
は、以下のコードでありますリモート3とリモート4)。
HiveServer2
は正常に動作していますが、Hive
は正しく動作していません。
私を助けてください。
実際のクエリ( 'select * from table_name limit 3;')をエスケープした一重引用符ではなく、エスケープした二重引用符を使用してみましたか? – mscdex
はい。まだ動作していません。 .exec( 'timeout 900 ssh -i' + rsaPath + '' + hiveStageNodes + 'のiのためのhealthDevHost +' \; clush -w $ {i} "hive -e \" base.merlin_tagからの選択* "; done; \ '') – aiman
申し訳ありませんが、ダブルエスケープされた引用符(' \\ "')を意味します。そうでないと、サーバは次のようなコマンドを表示します: 'timeout 900 ssh -i /foo.key foo.bar .baz 'for foo; for cloo -w $ {i} "hive -e" select * from base.merlin_tag limit 3 ""; done;' ' – mscdex