[ python-Bugs-1008275 ] os.getstatusoutput on win32 (original) (raw)

SourceForge.net noreply at sourceforge.net
Sat Aug 14 01:36:37 CEST 2004


Bugs item #1008275, was opened at 2004-08-13 07:28 Message generated for change (Comment added) made by ncoghlan You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1008275&group_id=5470

Category: Python Library Group: Python 2.3 Status: Open Resolution: None Priority: 5 Submitted By: Chmouel Boudjnah (chmou) Assigned to: Nobody/Anonymous (nobody) Summary: os.getstatusoutput on win32

Initial Comment: Using:

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32

i cannot run command.getstatusoutput since i guess it expect a unix shell.

import commands commands.getstatusoutput("c://usr//bin//echo") (1, "'{' n'est pas reconnu en tant que commande interne\nou externe, un programm e ex\x82cutable ou un fichier de commandes.")

i had to bypass it on win32 by using this in my program :

def _getstatusoutput(cmd): """Return Win32 (status, output) of executing cmd in a shell.""" pipe = os.popen(cmd, 'r') text = pipe.read() sts = pipe.close() if sts is None: sts = 0 if text[-1:] == '\n': text = text[:-1] return sts, text

Cheers, Chmouel. http://www.chmouel.com/wp/


Comment By: Nick Coghlan (ncoghlan) Date: 2004-08-14 09:36

Message: Logged In: YES user_id=1038590

The commands module is going to stay Unix-specific. There are too many potential issues with trying to support the various win32 command interpreters.

It will eventually be deprecated in favour of a higher level process management API. Hopefully that will happen in the 2.5 timeframe, but we'll have to wait and see.


Comment By: Nick Coghlan (ncoghlan) Date: 2004-08-13 19:29

Message: Logged In: YES user_id=1038590

Well, the docs for the commands module explicitly state that it is only supported on Unix.

While two of the functions it provides (getstatusoutput() and getoutput()) are trivial to provide on Windows, the 3rd (getstatus()) has no equivalent that I can see.

I think I'll take this one to py-dev for further consideration


You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1008275&group_id=5470



More information about the Python-bugs-list mailing list