> How, in Python, can I execute a string as a shell command?

You should use the 'call' function of the 'subprocess' module.  You can
either pass it a string with the full command or a list of strings
comprising the command (like execv in libc).  You must pass the
'shell=True' option if you are passing the full string; otherwise it can
be omitted.

    import subprocess
    subprocess.call("ls -l /home/rms", shell=True)
    subprocess.call(["ls", "-l", "/home/rms"])

-brandon

-- 
Brandon Invergo
http://brandon.invergo.net

Attachment: pgpihniyntL0h.pgp
Description: PGP signature

_______________________________________________
gnu-misc-discuss mailing list
gnu-misc-discuss@gnu.org
https://lists.gnu.org/mailman/listinfo/gnu-misc-discuss

Reply via email to