我正在编写一个脚本来显示服务器NIC的所有IP,但我有一个问题。你知道吗
如何在Python的sh
模块中正确使用变量?你知道吗
我的代码示例:
allinterfaces = os.popen('/sbin/ifconfig -s |awk {\'print $1\'} |grep -v Iface')#.read().strip()
for interface in allinterfaces:
print interface
print sh.grep(sh.ifconfig('eth0'), "-oP", "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}")
我的问题是:如何更改变量的“eth0”?你知道吗
相关问题 更多 >
编程相关推荐