使用fabric获取远程python版本
我是 Fabric 新手,到目前为止我能够使用所有基本功能、连接和执行 bash 命令。但我也尝试执行 python 命令来验证正在运行的版本和其他内容。
但就版本而言,如何使用 fab 获取远程 python 版本。
更新(错误详细信息): 这是我得到的输出
[192.168.3.139] run: python --version
[192.168.3.139] out: Python 2.7.1+
[192.168.3.139] out:
Traceback (most recent call last):
File "/home/mo/Projects/mazban/lib/python2.6/site-packages/fabric/main.py", line 723, in main
task(*args, **kwargs)
File "/home/mo/Projects/mazban/mazban/fabfile.py", line 203, in firstrun
version = run("python --version").split()[2]
IndexError: list index out of range
Disconnecting from 192.168.3.139... done.
I am new to Fabric, and so far I am able to use all the basic functionality, connect and execute bash commands. But I am trying to execute python commands too to verify the running version and other things.
but as far as the version goes, how can I get the remote python version with fab.
UPDATE (Error details):
Here is the output I got
[192.168.3.139] run: python --version
[192.168.3.139] out: Python 2.7.1+
[192.168.3.139] out:
Traceback (most recent call last):
File "/home/mo/Projects/mazban/lib/python2.6/site-packages/fabric/main.py", line 723, in main
task(*args, **kwargs)
File "/home/mo/Projects/mazban/mazban/fabfile.py", line 203, in firstrun
version = run("python --version").split()[2]
IndexError: list index out of range
Disconnecting from 192.168.3.139... done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是最简单的解决方案:
注意:在我的系统上,输出的第一行是“BASHRC”,这就是您需要执行
[2]
的原因。This is probably the easiest solution:
Note: on my system, the first line of output is "BASHRC", which is why you need to do
[2]
.