0

Basically, os.system() can execute shall commands, such as:

os.system("echo $A")

It will work well and output value environment variable A.

But this seems to not work:

os.system("A=b echo $A")

It won't output "b" as expected.

How Python can execute this type of command command?

1
  • 1
    "A=b; echo $A" seems to work Commented Nov 12, 2022 at 3:14

1 Answer 1

0

It won't output "b" as expected.

The expansion $A to empty string is done by the shell earlier, before running echo.

Try this:

os.system("A=b; echo $A")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.