I am trying to redirect(in windows) the output of a python file to the stdin of a command created with boost::program::options like this:
python test.py | command.exe -s
test.py just prints the content of a file:
f = open('test.xml', 'r')
print f.read()
f.close()
If i execute just the python file it works but if i try to pipe it to the other command it fails with the following error:
close failed in the file object destructor:
sys.excepthook is missin
lost sys.stderr
If i try to execute this command.exe -s < test.xml
it works fine so i guess is a problem with pipe.
Does anyone have an idea what is happening?
You get this error because when CMD is creating pipe, it's closing STDERR. And somehow method close()
of file obejct in python need to use this descriptor which is missing.
And possible solution could be like this : https://superuser.com/questions/452763/how-to-pipleline-stderr-in-cmd-exe