I am modifying the environmental variable TMPDIR inside of a python script so a bash script can use it as a working space. Here is a sample of how I am doing it.
import subprocess as sp
import os
os.environ['TMPDIR'] = "./tmp"
print "Use python to set the tmpdir to:"
print os.environ['TMPDIR']
sp.Popen('bash test_bash',shell=True)
for testing my script test_bash just has
#! /bin/sh
echo "test_bash should show TMPDIR Path here:"
echo "----> $TMPDIR"
The output is
Use python to set the tmpdir to:
./tmp
test_bash should show TMPDIR Path here:
---->
When I change the name variable TMPDIR to anything else, my code works.
Does sp.Popen() protect $TMPDIR? And if so is there a right way I can modify it?
I would just use another variable name except I am working on a large project where $TMPDIR is used heavily in both python and bash. The goal is to use this in a shared environment and allow users to specify a working dir to avoid over-writing each other.
Things I have tried: