You call '.' shell. This command means "execute this shell file in the current process." You cannot execute a shell file in a Python process, because Python is not a shell script interpreter.
/home/b2v95/sqllib/db2profile, , . system(), , ( script).
python script - script, . /home/b2v95/sqllib/db2profile python script.
- , db2profile. NAME=value, python script os.environ . script - (, - ), script Python.
: script python, ( Popen) script write env , , . .
- :
shell = subprocess.Popen(["sh"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
script = open("/home/db2v95/sqllib/db2profile", "r").read()
shell.stdin.write(script + "\n")
shell.stdin.write("env\n")
shell.stdin.close()
for line in shell.stdout:
name, value = line.strip().split("=", 1)
os.environ[name] = value