2016-06-14 1 views
0

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は正しく動作していません。
私を助けてください。

+0

実際のクエリ( 'select * from table_name limit 3;')をエスケープした一重引用符ではなく、エスケープした二重引用符を使用してみましたか? – mscdex

+0

はい。まだ動作していません。 .exec( 'timeout 900 ssh -i' + rsaPath + '' + hiveStageNodes + 'のiのためのhealthDevHost +' \; clush -w $ {i} "hive -e \" base.merlin_tagからの選択* "; done; \ '') – aiman

+0

申し訳ありませんが、ダブルエスケープされた引用符(' \\ "')を意味します。そうでないと、サーバは次のようなコマンドを表示します: '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

答えて

0

解決済みです。代わりにhive内部の単一引用符の
は、それはすなわち、代わりに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\' ',{
は私が
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\' ',{をしたライン、doulbeの引用符を必要とし、それが働きました。
あなたのサポートのために@mscdexに感謝します。

関連する問題