Save command output to variable
I have a python fabfile.py file. I want to store the result of a local command in a variable so that I can test it for different cases. For example, I want to do this ...
substring = "up-to-date"
msg = local("git pull")
if msg.find(substring) == -1:
"some action"
but I cannot save the output to the msg variable. How can i do this?
+3
source to share
3 answers