python - Expanding/substituting variables in a popen call -


I'm trying to call some shell programs that use the environment and I can detect it correctly I am trying. I was boiled under this snippet: pppen ("echo", "hello", "$ FOO"), env = {"FOO": "42"} , Stdout = sp.PIPE, shell = true) p.wait () print (p.communicate ())

When "shell" is set to true then print it "('' Hello $ FOO \ n ', none)", but I expected that I would print it on the lines of "Hello 43 \ n", none) ". Am I doing wrong and is there a better way to do this?

Try this:

  p = sp.Popen ("echo Hello $ FOO ", env = {" FOO ":" 42 "}, shell = True)   

Output must be" Hello 42 "

Comments

Popular posts from this blog

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -