You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alexander Ponomarev edited this page Jan 4, 2022
·
5 revisions
In simple mode you execute commands in a blocking way. That means that execution of
`ping -n 4 8.8.8.8
will not return until it is finished. When it's done a Result of the execution becomes available to you. You can assign the Result to your variable like this:
result = `ping -n 4 8.8.8.8
Result
Result is a class that provides several properties to you:
stdout property returns the whole text of the command stdout to you.
stderr the same but for stderr.
stdout_lines is a list of all stdout lines. It may be convenient if you want to iterate over all lines or access some specific line by index. Lines in this list do not contain the line separator at the end.
stderr_lines the same but for stderr.
returncode return code of the command executed
###Syntactic sugar
It is possible to iterate over lines of result
result = `ls -l somedir
for line in result:
print line.upper()