Running git commands using subprocess.Popen in python -
i writing small python script needs execute git commands inside given directory
the code follows:
import subprocess, os pr = subprocess.popen(['/usr/bin/git', 'status'], cwd=os.path.dirname('/path/to/dir/'), stdout=subprocess.pipe, stderr=subprocess.pipe, shell=true) (out, error) = pr.communicate() print out
but shows git usage output.
if command doesn't involve git eg. ['ls']
shows correct output.
is there missing ?
python version - 2.6.6
thanks.
on unix,
shell=true
: […] if args sequence, first item specifies command string, , additional items treated additional arguments shell itself.
you don't want shell=true
, list of arguments. set shell=false
.
Comments
Post a Comment