Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Feb 2002 22:07:17 -0500
From:      Eric I.Arnoth <earnoth@comcast.net>
To:        freebsd-questions@freebsd.org
Subject:   syslog.conf problems
Message-ID:  <20020221030958.QQRM18863.femail11.sdc1.sfba.home.com@there>

next in thread | raw e-mail | index | archive | help
If anyone replies to my message, please be sure to keep my email on the CC or 
TO fields, I do not subscribe to this list.

I've been trying to get a script which will take the output from syslog and 
handle it, but I can't get past the hello world stage.  I've tried a bourne 
shell script and a python script (which is the language I want to write the 
end-result in).  With the bourne shell script, I get countless error messages 
like the following, with decrementing subprocess IDs:

-----------------------------------------------------
Feb 20 21:39:10 systemname syslogd: Logging subprocess 1894 (exec 
/hello_log.sh) exited with status 126.
Feb 20 21:39:10 systemname syslogd: exec /hello_log.sh: Broken pipe
-----------------------------------------------------

Here's the bournshell script hello_log.sh:
-----------------------------------------------------
#!/bin/sh
read line
echo "$line" >> /test.out
-----------------------------------------------------

With the Python script, I only get output after I HUP the syslogd process.  I 
get all the output I should, but I want it processed real-time by a 
run-once-and-die script.

Here's a few variations of the python script I've tried:
-----------------------------------------------------
#!/usr/local/bin/python
import sys

test_file = open("/test.out", 'a')
test_file.write(sys.__stdin__.read())
test_file.flush()
test_file.close()
sys.exit()
-----------------------------------------------------
#!/usr/local/bin/python
import sys

test_file = open("/test.out", 'a')
for char in sys.__stdin__.read():
	test_file.write(char)
	test_file.flush()
test_file.close()
sys.exit()
-----------------------------------------------------
#!/usr/local/bin/python
import sys

test_file = open("/test.out", 'a')
for char in sys.__stdin__.read():
	if char=='\012':
		test_file.write(char)
		test_file.flush()
		test_file.close()
		sys.exit()
	else:
		test_file.write(char)
		test_file.flush()
test_file.close()
sys.exit()
-----------------------------------------------------



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020221030958.QQRM18863.femail11.sdc1.sfba.home.com>