I have a command like
command = "su - user; cd $CONFIG; grep domain domains.xml"
And need to execute the commands one after other and capture the output of grep.
def subprocess_cmd(command):
fnlogs("comand = " + command)
process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True)
proc_stdout = process.communicate()[0].strip()
fnlogs("proc_stdout = " +proc_stdout + "\n")
subprocess_cmd('su - user; cd $CONFIG; grep domain domains.xml')
Output says grep: domains.xml: No such file or directory, although the file exists its not able to find it.