This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pierre_rouleau
Recipients
Date 2002-01-20.18:13:10
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
##commands.getstatusoutput(): Does not support for DOS-type shells
# -------------------------------------------------------------
# 
# Inside commands.py, the getstatusoutput() function is not capable of running a 
# DOS-type shell command.  The current code assumes that the operating system 
# is running a Unix-type shell.
# 
# The old code is:

def getstatusoutput(cmd):
    """Return (status, output) of executing cmd in a shell."""
    import os
    pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
    text = pipe.read()
    sts = pipe.close()
    if sts is None: sts = 0
    if text[-1:] == '\n': text = text[:-1]
    return sts, text


# I propose that we update that code to check the operating system and support 
# DOS-style shells (for DOS, NT, OS/2) with the following modified code:

def getstatusoutput(cmd):
    """Return (status, output) of executing cmd in a shell."""
    import os
    if os.name in ['nt', 'dos', 'os2'] :
       # use Dos style command shell for NT, DOS and OS/2
       pipe = os.popen(cmd + ' 2>&1', 'r')               
    else :
       # use Unix style for all others
       pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
    text = pipe.read()
    sts = pipe.close()
    if sts is None: sts = 0
    if text[-1:] == '\n': text = text[:-1]
    return sts, text

History
Date User Action Args
2007-08-23 13:58:48adminlinkissue506100 messages
2007-08-23 13:58:48admincreate