confused with subprocess.Popen

Matt Nordhoff mnordhoff at mattnordhoff.com
Sun May 10 05:21:43 CEST 2009


Soumen banerjee wrote:
> Hello,
> for a certain app, i used to use a command:
> os.system("soundwrapper espeak -f line.txt")
> now, if i wanted to kill espeak, i would have to run:
> os.system("killall espeak")
> since the subprocess module allows sending SIGKILL to the process, i
> decided to switch to using it. However i cant pass the spaced out
> arguments to it. For example:
> a=subprocess.Popen("soundwrapper espeak -f line.txt")
> results in a OSError, no such file or directory.
> How do i use the Popen function?
> Regards
> Soumen

Read subprocess's documentation. It takes a list, not a string:

>>> a = subprocess.Popen(["soundwrapper", "espeak", "-f", "line.txt"])
-- 



More information about the Python-list mailing list