the paths and files names are correct w upper / lower case.
And the read is listening to a pipe not reading a file (name)
this has worked for years, and for some it just stopped now. Also older plugin versions have the same issue.
this is a simplified version
- Code: Select all
#! /usr/bin/env python
# -*- coding: utf-8 -*-
####################
import subprocess
import fcntl
import os
import sys
import time
uid = "xx"
passwd = "xx"
ip = "192.168.1.xx"
#cmd= "/usr/bin/expect execLog.exp '"+uid+"' '"+passwd+"' "+ip+" BZ.v '/usr/bin/tail -F /var/log/messages'"
cmd = "/usr/bin/expect dictLoop.exp '"+uid+"' '"+passwd+"' "+ip+" BZ.v xxxThisIsTheEndTokenxxx 60 40 \"mca-dump | sed -e 's/^ *//'\" /var/log/messages"
print cmd
ListenProcess = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
# set the O_NONBLOCK flag of ListenProcess.stdout file descriptor:
flags = fcntl.fcntl(ListenProcess.stdout, fcntl.F_GETFL) # get current p.stdout flags
fcntl.fcntl(ListenProcess.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)
while True:
try:
linesFromServer = os.read(ListenProcess.stdout.fileno(),32767) ## = 32k
print unicode(linesFromServer)
except Exception, e:
if unicode(e).find("[Errno 35]") == -1: # "Errno 35" is the normal response if no data, if other error: exit
if len(unicode(e)) > 5:
print "os.read(ListenProcess.stdout.fileno(),32767) has error in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e)
print "... ListenProcess for ip: "+ip+" ListenProcessObject: "+ unicode(ListenProcess)
try: print "..."+ unicode(ListenProcess.stdout)
except: print "... ListenProcess.stdout not printable"
try: print "..."+ unicode(ListenProcess.stdout.fileno())
except: print "... ListenProcess.stdout.fileno() not printable"
time.sleep(1)