a-shell icon indicating copy to clipboard operation
a-shell copied to clipboard

Environment variables | Shortcuts

Open seexmax opened this issue 1 year ago • 1 comments

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

seexmax avatar May 04 '23 16:05 seexmax

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?

holzschu avatar May 04 '23 16:05 holzschu