a-shell
a-shell copied to clipboard
Environment variables | Shortcuts
environment variables return None value when called from shortcuts with python script
$ export TESTUSERNAME="[email protected]"
my_python_script.py :
import os
print(os.environ.get("TESTUSERNAME"))
works in shell
$ python my_python_script.py
[email protected]
return None
in shortcut with Open the app to execute the commands : no (run in extension) | Show When Run : On
![](https://user-images.githubusercontent.com/96994915/236262958-314ef41d-49e3-4cca-87a8-3da456de1bfc.jpg)
I think this is expected: the shortcuts running "in extension" are running, in practice, in a separate tiny app (the extension). They have a different environment, different access permissions, and so on.
You can set environment variables as part of the shortcut (calling export TESTUSERNAME="[email protected]"
before calling python my_python_script.py
) and that should work. Unless I misunderstood and you already tried that, in which case can I have a look at the Shortcut to get a better understanding?