These are some dependant commands i am trying to run. My expectation was it will change current folder to abc
& list files.
Also after setting z=88
, it will print z
.
import subprocess
cmd_list = []
cmd_list.append("cd ./abc")
cmd_list.append("ls")
cmd_list.append("export z=88")
cmd_list.append("echo $z")
my_env = os.environ.copy()
for cmd in cmd_list:
sp = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=my_env, shell=True,text=True)
But unable to get any output for ls
and echo $z