我尝试侦听新的文件行并在snmptraps
中重新发送:
#!/usr/bin/env python
import subprocess
sreader = "tail -f /root/zsv/log"
ssreader = subprocess.Popen(sreader,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
strap = 'snmptrap -c iptvinfo -v 2c 192.168.10.10:163 "" 1.3.3.3.3.3.3.3 1.2.2.2.2.2.2 s '
subprocess.Popen([strap + ssreader.communicate()[0]],shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
我什么也得不到。。 这是我的第一个程序,请帮我修一下
注意:
shell=False
默认情况下,stderr
不会被重定向。在您可以将代码更改为一次发送所有可用行,或者每分钟只发送一次。在
根据您的需要,您可以选择适合您的案例
tail -f
在Python中的实现。见How can I tail a log file in Python?和 Get last n lines of a file with Python, similar to tail。在相关问题 更多 >
编程相关推荐