I been trying to run the ksh script from python using subprocess and need some help as environment variable are not being resolved which are being used inside the script. Any advice on proper way to export the path for subprocess to pick.
Tried to echo the path but it return same value with being resolved
import os
import subprocess as sp
os.environ['b_dir'] = /path/script/
os.environ['data_dir'] = /path/data/
r0 = sp.run(['echo','$b_dir'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print(r0.stdout.decode())
r = sp.run(['ksh','$b_dir/dev/scriptname.ksh'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print(r.stdout.decode())
output of r0 was $b_dir
expecting: /path/script/