Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 将tty输出推送到节点_Bash_Node.js_Tty - Fatal编程技术网

Bash 将tty输出推送到节点

Bash 将tty输出推送到节点,bash,node.js,tty,Bash,Node.js,Tty,为了满足我的好奇心,我想玩bash/node组合。 我不知道如何让那两个人一起说话。我只是脸上挂着一个灿烂的笑容;-) 如何将终端的输出(sdtout?)馈送到节点?我考虑将流重定向到文件,并通过“fs”模块使用节点读取它。但我打赌一定有更漂亮的方式 提前感谢。类似的内容应该会将终端输出发送到节点 var app = require('express').createServer(), io = require('socket.io').listen(app), sys = re

为了满足我的好奇心,我想玩bash/node组合。 我不知道如何让那两个人一起说话。我只是脸上挂着一个灿烂的笑容;-)

如何将终端的输出(sdtout?)馈送到节点?我考虑将流重定向到文件,并通过“fs”模块使用节点读取它。但我打赌一定有更漂亮的方式


提前感谢。

类似的内容应该会将终端输出发送到节点

var app = require('express').createServer(),
    io = require('socket.io').listen(app),
    sys = require('util'),
    exec = require('child_process').exec;

app.listen(4990);

io.sockets.on('connection', function(socket) {
    socket.on('console', function(command, callBack) {
        // client sends {command: 'ls -al'}
        function puts(error, stdout, stderr) {
            socket.emit('commandresult', stdout);
        }
        exec(command.command, puts);
    });
});​
希望这能有所帮助

的确如此;-)非常感谢。