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

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -