slaughter98
slaughter98

Reputation: 1883

Modify current environment within python script

I would like to create a python tool for dynamically setting up my environment. I would like to be able to do the following.

$ echo $FOO

$ ./foo.py
$ echo $FOO
bar

If this is possible I would greatly appreciate assistance getting this working.

Upvotes: 0

Views: 43

Answers (1)

Davis Herring
Davis Herring

Reputation: 40023

It's impossible (because the Python process has its own environment). You can (though it might not be worthwhile) write a script whose output is commands for bash, and then write eval "$(./foo.py)".

Upvotes: 2

Related Questions