はい、できます。 child_process.spawn
。 child_process.exec
はコマンドを実行して出力をバッファしますが、spawn
はdata
,error
およびend
のイベントを出力します。あなたはそれを聞くことができ、あなたの進歩を計算することができます。 node docs for spawnには基本的な例があります。
更新:あなたの他の質問を見ました。これにはwget
を使用できますが、代わりにnodejsモジュールrequestをお勧めします。ここで要求してファイルを取得する方法は次のとおりです。
var request = require("request");
request(url, function(err, res, body) {
// Do funky stuff with body
});
あなたは進行状況を追跡したい場合は、onResponse
にコールバックを渡す:
function trackProgress(err, res) {
if(err)
return console.error(err);
var contentLength = parseInt(res.headers["content-length"], 10),
received = 0, progress = 0;
res.on("data", function(data) {
received += data.length;
progress = received/contentLength;
// Do funky stuff with progress
});
}
request({url: url, onResponse: trackProgress}, function(err, res, body) {
// Do funky stuff with body
});
あなたは卵はあなたのデータは、エラーと終了のイベントを提供します」と言っています"それでは、spawnを使ってPythonスクリプトの実行を進めることは可能ですか?はいの場合は、この質問にお答えください。 http://stackoverflow.com/questions/33802895/show-progressbar-of-python-script-execution-with-nodejs – AshBringer