stderr always coming in stdout
还没有人认领这个 Issue。
- #342 来自 @steelbrain —— 已关闭,未合并
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- node.js, typescript
- 领域
- networking
调研方向
从 ssh.exec 入口点开始,使用报告中的 pty、stdin 和 stream: 'both' 选项,然后跟踪命令输出是如何分配给 result.stdout 和 result.stderr 的。重现 sudo apt updat 的情况,并确认错误文本被分离到 result.stderr 中,同时退出代码仍为 100。
由索引模型根据 Issue 内容生成。
描述
Hi,
I have faced an issue, which always returns stderr in result.stdout rather than result.stderr.
node-ssh version 10.0.2
ssh.connect({
host: 'localhost',
username: '<username>',
password: '<password>'
}).then(() => {
ssh.exec('sudo apt updat', [], {
execOptions: { pty : true },
stdin: '<password>\n',
stream: 'both'
}).then((result) => {
console.log("Result StdOut", result.stdout)
console.log("Result StdErr", result.stderr)
console.log("Result", result)
})
})
Note: Intensively I make an error in the command sudo apt updat to expecting error.
When I execute above code I got the error always in the stdout.
Result StdOut
[sudo] password for <username>:
E: Invalid operation updat
Result StdErr
Result {
code: 100,
signal: null,
stdout: '<password>\r\n' +
'[sudo] password for <username>: \r\n' +
'\u001b[1;31mE: \u001b[0mInvalid operation updat\u001b[0m',
stderr: ''
}
But the same is working expected using ssh2
Below is the sample.
var Client = require('ssh2').Client;
var conn = new Client();
conn.on('ready', function() {
console.log('Client :: ready');
conn.exec('apt updat', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
console.log('Stream :: close :: code: ' + code + ', signal: ' + signal);
conn.end();
}).on('data', function(data) {
console.log('STDOUT: ' + data);
}).stderr.on('data', function(data) {
console.log('STDERR: ' + data);
});
});
}).connect({
host: 'localhost',
port: 22,
username: '<username>',
password: '<password>'
});
Output is
STDERR:
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
STDERR: E: Invalid operation updat
STDERR:
Stream :: close :: code: 100, signal: undefined
- 主要语言
- TypeScript
- 星标
- 1k
- 派生
- 94
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
steelbrain/node-ssh 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
steelbrain/node-ssh#487 ·
-
难度 5/5 一周以上 新手友好度 35/100
steelbrain/node-ssh#482 · 3 条评论 ·
-
难度 3/5 1-2 天 新手友好度 45/100
steelbrain/node-ssh#474 · 3 条评论 ·
-
难度 3/5 1-2 天 新手友好度 35/100
steelbrain/node-ssh#473 · 1 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 20/100
steelbrain/node-ssh#472 ·
查看 steelbrain/node-ssh 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
-
cli: `execCargoMetadata` decodes stdout per chunk, corrupting non-ASCII paths across pipe boundaries未关闭
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1 小时以内 新手友好度 62/100
lingdojo/kana-dojo#34127 · 1 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 68/100
osmlab/name-suggestion-index#13104 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100