nodejsスクリプト内に、呼び出しを同期的に行い、呼び出しているシェルスクリプトからstdoutを返す次のコードがあります。
var sh = require('shelljs');
... some code
var output = sh.exec('./someshellscript.sh', {silent:true}).stdout;
console.log(output);
... some more code (that shouldnt run until the script is complete)
代わりに stderr を返す次のスクリプトを実行することもできます。
var sh = require('shelljs');
... some code
var output = sh.exec('./someshellscript.sh', {silent:true}).stderr;
console.log(output);
... some more code (that shouldnt run until the script is complete)
ただし、同期呼び出しで stdout と stderr の両方を受け取りたいです。それはおそらく、私がここで見逃しているかなり明白なものですが、解決できません。
以前のバージョンでは次のコマンドを実行できたと思いますが、現在は undefined が返されます。
var sh = require('shelljs');
... some code
var output = sh.exec('./someshellscript.sh', {silent:true}).output;
console.log(output);
... some more code (that shouldnt run until the script is complete)
関連するソフトウェア バージョンは次のとおりです。
- Ubuntu: 14.04.3 LTS
- ノード: 4.4.4
- npm: 2.15.1
- shelljs: 0.7.0
どんな助けでも感謝します。