I have a variable in python, and I'm trying to open a subprocess and echo the variable, then create a file with the variable in it. I tried this:
subprocess.Popen(['echo "$var" > file.txt'], shell=True)
It creates the file, but it's empty. How can I get the result that I want?