问题
I'm executing a python script from within node using execSync like this:
execSync('python myScript.py -o "/dev/stdout"');
My script will send the result to the file specified at -o
in this case /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.
I'm running Ubuntu 12.04.
回答1:
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.
If you read a bit further down the execsync page, it describes how to use a child process' stdout
来源:https://stackoverflow.com/questions/40288461/no-such-device-or-address-dev-stdout