def METHOD_NAME(command, outfile=None):
    # shlex.split will preserve inner quotes
    p0 = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
    stdout0, stderr0 = p0.communicate()
    rc = p0.returncode
    p0.stdout.close()
    p0.stderr.close()
    if outfile:
        try: cf = open(outfile, 'wb')
        except IOError:
            print("ERROR: unable to open file for writing")
        else:
            cf.write(stdout0)
            cf.write(stderr0)
            cf.close()
    else:
        print("    ", stdout0)
        if stderr0:
            print("    ", stderr0)
    return rc