Tag: shell

节点安装,但不是NPM

我用brew'brew install node'安装了节点,并且收到警告消息 'Warning: The post-install step did not complete successfully'. 当我放入节点-v,我确实可以看到当前版本的节点,但是当我试图find当前版本的npm时,我得到这个错误。 -bash: /usr/local/bin/npm: No such file or directory 是否因为安装后步骤没有成功完成而导致NPM不存在?

subprocessNode.js中的stdout和stderr列大小

我想监视来自Node中subprocess的实时数据。 我可以做到这一点没有问题,下面的代码片段。 var fs = require('fs'); var spawn = require('child_process').spawn; (function(){ "use strict"; var processMonitor, processListen, processDeauth; var parseStreamDataIn = function(data) { var str = data.toString('utf8'); console.log(str); }; var init = function() { processMonitor = spawn('trafficmon' , ['-w'], {'shell': '/bin/bash'}); processMonitor.stdout.on('data', function (data) { //trafficmon uses stderr, nothing needed here… }); processMonitor.stderr.on('data', parseStreamDataIn); processMonitor.on('close', function […]

在gocdpipe道上运行nodejs命令

我创build了一个新的gocd pipeline并有三个shell script文件在不同的阶段运行。 问题是代理不知道npm 。 Note:我在安装了go代理的机器上安装了npm,并且手动从pipe道运行了shell脚本。 这是我的shell脚本来安装软件包。 #!/bin/sh npm install 错误: 01:34:43.674 [go] Start to execute task: <exec command="./install.sh" />. 01:34:43.680 ./install.sh: line 3: npm: command not found 01:34:43.814 [go] Current job status: failed.

编写节点Shell脚本时未find命令

我正在尝试使用Node.js创build一个类似于像express和mocha这样的包的shell脚本。 我的初步testing报告命令没有find,所以我支持以下脚本: #!/usr/bin/env node console.log("printing stuff"); 以上应该只是输出“打印的东西”时运行; 但是,这也是行不通的。 我试图通过文件目录中的./script执行脚本,以确保它不是一个path问题。 尝试在特权状态(即sudo)下执行会产生相同的结果/错误消息。 任何想法我需要做什么?

如何从节点js服务器向客户端显示shell脚本的结果?

我有一个节点js服务器,它触发我有一个shell脚本。 代码如下(简单的Hello World例子): var http = require("http"); function onRequest(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); var spawn = require('child_process').spawn; //executes my shell script – main.sh when a request is posted to the server var deploySh = spawn('sh', [ 'main.sh' ]); //This lines enables the script to output to the terminal deploySh.stdout.pipe(process.stdout); //Simple response to […]

运行节点作为从subprocess运行的脚本的后台进程

我正在端口5100上运行一个节点服务器。它执行一个shell脚本作为subprocess,然后启动另一个节点服务器。 var execFile = require('child_process').execFile; execFile("./testscript", args, {cwd: cwd}, function (error, stdout, stderr) { console.log("error.." + error); console.log("stdout.." + stdout); console.log("stderr.." + stderr); }) 在脚本中,我正在通过nohup运行一个节点进程: nohup node server.js PORT=5200 2>/dev/null 1>/dev/null & 现在,node @ 5200拥有了对@ 5100节点的testing脚本的支持。 当我杀死节点@ 5100的PID时,一切都停止。 我希望node @ 5200在testscript和node @ 5100退出时仍然运行。

npm如何运行?

当我inputnpm run <command>时会发生什么? 将<command>传递给sh shell,如下所示: sh -c <command> 与额外的本地variables添加到shell,即pathnode_modules/.bin ? 我以为npm只能通过使用节点在JavaScript中工作,但似乎还有很多事情要做。 如何处理&& ? globstar是否安全使用?

未find命令:P​​HP exec()

这真让我抓狂。 我需要php执行一个命令重新启动节点中运行的脚本。 我正在使用名为forever的节点应用程序来运行该脚本。 代码如下: <?php echo '<pre>'; echo exec('sudo -u dalton forever restart botti.js 2>&1'); echo '</pre>'; ?> 但是,当我运行,我得到sudo: forever: command not found 接下来,我尝试which forever type forever ,这两个给我: forever: /usr/local/bin/forever 我编辑我的代码: echo exec('sudo -u dalton /usr/local/bin/forever restart botti.js 2>&1'); 编辑:错字后,现在的错误是: /usr/bin/env: node: No such file or directory 我在智慧的结尾。 有任何想法吗?

在使用命令:./script时运行Shell脚本,但不是命令:脚本,其中PATH = .:'usr / bin':etc

我正在运行Zsh,当前目录在我的path中,但是脚本在没有./情况下不能运行 阅读在terminal中执行的这些语句以了解上下文( »是我的shell提示字符): » ls Makefile node_modules package.json README.md src test tst » echo $PATH .:[all_my_other_directories] » cat test echo "test"; nodeunit tst/ » ./test test OK: 2 assertions (1ms) » test » which test ./test 注意在which test点上是正确的,但是test不会运行它。 我知道把我的本地目录放在我的path前是一个不好的主意,但是我已经改变了path. 在最后,它不会改变任何东西。 我将不胜感激任何帮助!

将string转换为shell参数

我感兴趣的是如何parsingbashinput到参数。 例如,通过使用process.argv我们在NodeJS中获得了一个string数组(但是这是语言不可知的)。 我的问题是如何parsing像"node foo.js –foo "bar baz" -b foo"input到类似于process.argv (或其他语言的等价物)返回(例如["node", "foo.js", "–foo", "\"bar baz\"", "-b", "foo"] ? 由空间分割是不够的(由于报价)。 是否有可能用一些更复杂的正则expression式来处理引号并得到这样一个数组?