[ python-Bugs-1463104 ] problems with os.system and shell redirection on Windows XP

SourceForge.net noreply at sourceforge.net
Wed Apr 5 20:40:39 CEST 2006

Bugs item #1463104, was opened at 2006-04-02 13:18
Message generated for change (Comment added) made by tim_one
You can respond by visiting: 

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
>Group: 3rd Party
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Manlio Perillo (manlioperillo)
Assigned to: Nobody/Anonymous (nobody)
Summary: problems with os.system and shell redirection on Windows XP

Initial Comment:
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310
32 bit (Intel)] on win32 - Windows XP SP2

N.B. sorry for italian error messages.

With the following script:

# redirection.py
import os
import sys



When doing:
redirection.py "dir" > redirection.txt

I obtain:
Spazio su disco insufficiente.

Instead with:
redirection.py "svn help" > redirection.txt

svn: Errore di scrittura: Bad file descriptor

This is a Python problem because with an equivalent
program written in C++:

// redirection.c++
#include <cstdlib>

int main(int argc, char** argv) {


there are no problems.

Thanks and regards  Manlio Perillo


>Comment By: Tim Peters (tim_one)
Date: 2006-04-05 14:40

Logged In: YES 

Sorry, there's nothing Python can do about this -- it's a
well-known family of Windows bugs, and affects all scripts
(regardless of language) that try to combine command line
I/O redirection with implicit determination of the
executable via file association.  As you've discovered, it
doesn't effect .exe files (which is why your C++ example
isn't relevant).  Various versions of Windows fail in
various ways, but in no version of Windows to date have all
the redirections bugs been fixed.

For example, here I'll reproduce your symptoms exactly with
Perl scripts on WinXP, although the error messages are English:

C:\Perl\bin>type blah1.pl

C:\Perl\bin>blah1.pl > out.txt
There is not enough space on the disk.

C:\Perl\bin>type blah2.pl
system("svn help");

C:\Perl\bin>blah2.pl > out.txt
svn: Write error: Bad file descriptor

The simplest and most reliable workaround is to put the path
to the executable first on the command line.  Here are the
same Perl examples doing that; the same kind of thing works
for all cases in which Windows redirection doesn't work
(including, of course, Python):

C:\Perl\bin>.\perl blah1.pl > out.txt

C:\Perl\bin>type out.txt
 Volume in drive C has no label.
 Volume Serial Number is 5C0F-48E6

 Directory of C:\Perl\bin

04/05/2006  02:29 PM    <DIR>          .
04/05/2006  02:29 PM    <DIR>          ..
02/04/2003  03:35 PM            90,175 a2p.exe

C:\Perl\bin>.\perl blah2.pl > out.txt

C:\Perl\bin>type out.txt
usage: svn <subcommand> [options] [args]
Subversion command-line client, version 1.2.3.


You can respond by visiting: 

More information about the Python-bugs-list mailing list