Getting parameters from environment variables

I want to read a new environment variable from my script. I am trying to export this var via ssh. I tried

test = "qwerty" cmd = "export my_password=%s;python script.py" % test 

execute this command with the ssh command. In the script:

 if os.environ.has_key("my_password"): print "ok" else: print "failed" 

As a result, I got a "failure." How do I set this env variable?

+4
source share
1 answer

Just add it before the command without exporting it:

 cmd = "my_password=%s python script.py" % test 
+3
source

All Articles