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: Output must be" Hello 42 "
p = sp.Popen ("echo Hello $ FOO ", env = {" FOO ":" 42 "}, shell = True)
Comments
Post a Comment