使用 ls、pwd 等简单命令,甚至打开外部应用程序,我可以成功使用子进程,但是当在构建的电子应用程序中使用 exec 和 docker 命令时,我收到此错误:
exec Error: Command failed: docker exec -it 6bec55e9e86e touch home.html
the input device is not a TTY
Run Code Online (Sandbox Code Playgroud)
这是代码:
var exec = require('child_process').exec;
exec('docker exec -it 6bec55e9e86e touch casa.html', function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
Run Code Online (Sandbox Code Playgroud)
请删除-t标志。所以你的命令应该是docker exec -i 6bec55e9e86e touch casa.html。
这个错误the input device is not a TTY意味着你的输入设备不是 Teletypes(terminal),并且在 docker 的命令中,-t标记符号 a terminal,所以它们是冲突的。所以只需将其删除即可。
| 归档时间: |
|
| 查看次数: |
2113 次 |
| 最近记录: |