没有这样的设备或地址:'/dev/stdout' [英] No such device or address: '/dev/stdout'

查看:45
本文介绍了没有这样的设备或地址:'/dev/stdout'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 execSync 像这样:

I'm executing a python script from within node using execSync like this:

execSync('python myScript.py -o "/dev/stdout"');

在这种情况下,我的脚本会将结果发送到 -o 指定的文件中,在这种情况下为 /dev/stdout.

My script will send the result to the file specified at -o in this case /dev/stdout.

我收到错误消息没有这样的设备或地址:'/dev/stdout'".

I get the error message "No such device or address: '/dev/stdout'".

如果我从终端手动执行命令,它运行良好,但在通过节点启动时就不行.

If I execute the command manually from the terminal it runs fine, but not when started via node.

我运行的是 Ubuntu 12.04.

I'm running Ubuntu 12.04.

推荐答案

当您在终端中运行命令时,/dev/stdout 重定向到终端 stdout.当您使用 execSync 生成 python 进程时,stdout 没有被重定向到的地方.

When you run the command in a terminal, /dev/stdout redirects to the terminal stdout. When you spawn the python process with execSync there's no place for stdout to be redirected to.

如果您进一步阅读 execsync 页面,它描述了如何使用 子进程的标准输出

If you read a bit further down the execsync page, it describes how to use a child process' stdout

这篇关于没有这样的设备或地址:'/dev/stdout'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆