源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

JavaScript 用Node.js写Shell脚本[译]

  • 时间:2020-08-29 03:45 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:JavaScript 用Node.js写Shell脚本[译]
访问参数 你可以通过process.argv来访问到命令行参数,它是一个包含下列内容的数组: [ nodeBinary, script, arg0, arg1, ... ] 也就是说,第一个参数是从process.argv[2]开始的,你可以像下面这样遍历所有的参数:
[url=http://nodejs.org/docs/latest/api/stdio.html#stdio_console_log_data]console.log[/url]和浏览器中一样.console是一个全局对象,不是一个模块,也就不需要使用require()导入. [*][b]读取标准输入(stdin):[/b] [url=http://nodejs.org/api/process.html#process_process_stdin]process.stdin[/url]是一个[url=http://nodejs.org/api/stream.html#stream_readable_stream]readable stream[/url].process是一个全局对象.[/*] [*][b]运行shell命令:通过[/b][url=http://nodejs.org/docs/latest/api/child_process.html]child_process.exec().[/url][/*][/list]相关文章 [list=1] [*][url=http://www.2ality.com/2011/05/load-source-in-node.html]Tip: load source from a file in the Node.js shell[/url][/*] [*][url=http://www.2ality.com/2011/11/node-repl-start.html]Execute code each time the Node.js REPL starts[/url][/*][/list]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部