1.使用subprocess模块的Popen和communicate函数可以实现,具体方法如下:
#get interface speed
cmd = "ethtool %s | grep Speed " % name
inter_speed = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
speed = inter_speed.communicate()
print speed
1.使用subprocess模块的Popen和communicate函数可以实现,具体方法如下:
#get interface speed
cmd = "ethtool %s | grep Speed " % name
inter_speed = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
speed = inter_speed.communicate()
print speed