While using python3 subprocess.run()
, I need to got/access my home directory. I tried the below commands but their syntax is incorrect. Please advice me on the correct syntax that I should use. Thank you.
Test Script:
import subprocess as sp
sp.run(['cd', '$HOME'], stdout=sp.PIPE, stderr=sp.PIPE)
sp.run(['cd', '${HOME}'], stdout=sp.PIPE, stderr=sp.PIPE)
sp.run(['cd', '~'], stdout=sp.PIPE, stderr=sp.PIPE)