CNode

将nodejs文件变成可执行脚本

Iironheart发布于14 年前最后回复14 年前0 回复10583 浏览0 收藏

chmod +x testsh.js testsh.js文件如下

#! /usr/local/bin/node
var command = [];
command.push('ls');
command.push('top');
var filterstring = process.argv[2] || '';
var filteredcommand = command;
filteredcommand = command.filter(
function( tmp ){

	return( tmp === filterstring );

}
);

if(filteredcommand.length > 0) {
console.log('i got command ' + filteredcommand);
}

运行 ./testsh.js ls

查看回复

回复 (0)

暂无回复,成为第一个参与讨论的人。
参与回复
登录后即可参与回复。登录