> 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 Invergo

Attachment: pgpihniyntL0h.pgp
Description: PGP signature

gnu-misc-discuss mailing list

Reply via email to