I am trying to execute the bash script while :; do afplay beep.wav ; done
command from a python script, but be able to kill it afterwards.
I tried:
process = subprocess.Popen("exec while :; do afplay %s ; done" % fileName, shell=True, executable='/bin/bash')
as this answer suggests, but the above doesn't work for me. (The script doesn't run.)
How can I run while :; do afplay beep.wav ; done
from python and kill it at any point after it is started?
EDIT: just noticed that exec >(while :; do afplay %s; done)
will launch the script, but now process.kill()
won't kill it.