擅长:python、mysql、java
<p>为了让主机在fab命令行工具和fabfile.py之外的脚本中工作,<a href="http://docs.fabfile.org/en/1.10/api/core/tasks.html#fabric.tasks.execute" rel="nofollow noreferrer">you'll have to use execute()</a>:</p>
<pre class="lang-py prettyprint-override"><code>from fabric.api import run
from fabric.tasks import execute
def mytask():
run('uname -a')
results = execute(mytask)
</code></pre>