[ python-Bugs-891832 ] commands module doesn't support background commands

SourceForge.net noreply at sourceforge.net
Fri Feb 6 09:57:06 EST 2004


Bugs item #891832, was opened at 2004-02-06 08:57
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=891832&group_id=5470

Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Nobody/Anonymous (nobody)
Summary: commands module doesn't support background commands

Initial Comment:
The structure of the command passed to os.popen()
prevents the getoutput() and getstatusoutput() functions
from accepting commands for background
execution.  I think it would be sufficient to see if the
last non-whitespace character in the command was '&'
and if so, suppress insertion of the semicolon into the
command passed to os.popen():

  dosemi = not cmd.strip()[-1:] == '&'
  pipe = os.popen('{ %s%s } 2>&1' %
                         (cmd, dosemi and ';' or ''), 'r')

The above is untested, but based on my fiddling at the
shell prompt seems to be what's called for.

Since the status and output mean little or nothing
when the command is executed in the background,
perhaps a better alternative would be to add a new
function to the module which doesn't return either,
but dumps stdout and stderr to /dev/null.


----------------------------------------------------------------------

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



More information about the Python-bugs-list mailing list