------------------------------------------------------------------------------------------------
import subprocess
def bash_command(cmd):
subprocess.Popen(cmd, shell=True, executable='/bin/bash')
bash_command('a="Apples and oranges" && echo "${a/oranges/grapes}"')
------------------------------------------------------------------------------------------------
Sortie:
------------------------------------------------------------------------------------------------
Apples and grapes
------------------------------------------------------------------------------------------------
OU si probleme:
------------------------------------------------------------------------------------------------
import subprocess
def bash_command(cmd):
subprocess.Popen(['/bin/bash', '-c', cmd])
------------------------------------------------------------------------------------------------
Source 1:
http://www.saltycrane.com/blog/2011/04/how-use-bash-shell-python-subprocess-instead-binsh/
Source 2:
http://jimmyg.org/blog/2009/working-with-python-subprocess.html