我想弄清楚,如果它可能從一個用戶從shell運行一個node.js腳本暫停腳本,輸入一些輸入如冗長級別,然後讓腳本繼續執行。基本上我想在腳本實際運行時更改變量名稱(詳細程度)。我唯一的想法是用setInterval
每隔幾秒解析一個配置文件並重新載入執行參數。是否可以暫停node.js腳本,提示用戶輸入,然後重新啓動腳本?
0
A
回答
1
使用fs.watch()來檢測配置文件變更http://nodejs.org/api/fs.html#fs_class_fs_fswatcher
例如
// Require the file system
fs = require("fs");
// Watch the sim directory
fs.watch("text.txt", { persistent: true }, function (event, fileName) {
console.log("Event: " + event);
console.log(fileName + "\n");
});
0
您可以詢問用戶,只要你想顯示終端問題(像提示)寫你的變量名。 stdio模塊可以幫助你做很多事情。例如,當您需要用戶輸入時,您可以編寫以下內容:
var stdio = require('stdio');
stdio.question('What is your variable name?', function (err, varname) {
console.log('Your var name now is "%s"', varname);
// Do here whatever you want with varname
});
我希望這有助於。我是stdio
創建者。 :-)
相關問題
- 1. Javascript - 你可以暫停表單提交,然後重新啓動
- 2. 停止腳本,然後重新啓動它?
- 3. 如何暫停硒webdriver的腳本,並輸入驗證碼,然後腳本再次啓動
- 4. bash腳本用戶輸入提示
- 5. 重新啓動腳本的腳本
- 6. 自動啓動和停止node.js腳本
- 7. 自動啓動和停止node.js腳本
- 8. 腳本如何知道用戶是否可以輸入?
- 9. 是否可以暫停正在運行的R腳本?
- 10. 是否可以從用戶輸入重新啓動程序?
- 11. OS X shell腳本:如何暫停執行,直到Finder重新啓動後?
- 12. 如何暫停腳本,直到用戶輸入發生
- 13. 暫停CS腳本
- 14. jquery腳本暫停
- 15. 是/否用戶提示繼續或停止腳本
- 16. 是否可以使用node.js從URL導入腳本?
- 17. 是否可以在SLURM中暫停當前正在運行的提交腳本?
- 18. 是否可以在apache啓動時啓動一個php腳本?
- 19. 爲node.js啓動腳本repl
- 20. Powershell腳本 - 搜索AD,然後重新啓動服務
- 21. 安裝腳本運行,然後重新啓動並繼續
- 22. 啓動Vagrant VM並通過shell腳本啓動Node.js腳本
- 23. 從本身重新啓動python腳本
- 24. Google Apps腳本是否可重入?
- 25. 啓動Chrome,並啓動時暫停JS腳本
- 26. 啓動 - 停止 - 重新啓動shell腳本的功能
- 27. Linux腳本啓動,停止,重新啓動
- 28. 是否可以將node.js腳本插入到php代碼中?
- 29. 是否可以標記和保存特定的bash腳本行號,並重新啓動腳本保存位置?
- 30. 腳本停止/重新啓動本地SQL服務
更改變量*名稱*或變量*值*? – mscdex
冗長的變量值,正如我所見。 –
「var limit = 100」之類的值;或'var verbosity = 1'; – chovy