I'm getting error when shell=False
with sub process call but it's working when shell=True
.
String = "geeks"
CriticalCmd = "/bin/sed -i /^cu\\:/c\\ '%s' a" %String.rstrip('s')
subprocess.call((replaceHashCmd),shell=False)
I'm getting error when shell=False
with sub process call but it's working when shell=True
.
String = "geeks"
CriticalCmd = "/bin/sed -i /^cu\\:/c\\ '%s' a" %String.rstrip('s')
subprocess.call((replaceHashCmd),shell=False)
It's propbably because you calling subprocess.call
with a tuple of one string and not list of strings (as the arguments of the shell)
change:
subprocess.call((replaceHashCmd),shell=False)
to:
subprocess.call(replaceHashCmd.split(' '),shell=False)
.split
allow me to cut the string into the argument that i pass to the command line, like doing this :'ls -l'.split() # ['ls', '-l']
which is all the args you passing to the command line
consider reading this post: link