def runcmd(command, command_input=None, cwd=None):
proc = subprocess.Popen(command, stdin=subprocess.PIPE,<EOL>stdout=subprocess.PIPE,<EOL>stderr=subprocess.PIPE,<EOL>cwd=cwd)<EOL>(stdout, stderr) = proc.communicate(command_input)<EOL>if proc.returncode != <NUM_LIT:0>:<EOL><INDENT>sys.stderr.write('<STR_LIT>'<EOL>'<STR_LIT>' % (command, proc.returncode,<EOL>stdout, stderr))<EOL>sys.exit(proc.returncode)<EOL><DEDENT>return proc.returncode, stdout, stderr<EOL>
Run a command, potentially sending stdin, and capturing stdout/err.