Message1628

Author pekka.klarck
Recipients
Date 2007-06-12.14:12:57
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
If command given to os.popen is unicode redirecting stderr to stdout (2>&1) or either stdout or stderr to a file (>out.txt or 2>err.txt) fails. What happens is that the part that should take care of redirecting is given to the command as an argument and not stripped by the operating system.

As the example below demonstrates everything works ok if the command is a normal string. I also tested this with CPython 2.5 and there unicode was not a problem. Haven't tested using any other popen variant.


Jython 2.2b2 on java1.5.0_11
Type "copyright", "credits" or "license" for more informati
>>> import os
>>> for cmd in [ 'echo foo', 'echo foo 2>&1' ]:
...   p = os.popen(cmd)
...   print 'str:', p.read()
...   p.close()
...   p = os.popen(unicode(cmd))
...   print 'uni:', p.read()
...   p.close()
...
str: foo

uni: foo

str: foo

uni: foo 2>&1
History
Date User Action Args
2008-02-20 17:17:50adminlinkissue1735774 messages
2008-02-20 17:17:50admincreate