Hi,
Playing with syslog recently, I found a strange behaviour at some point and I am looking for some explanation.
From man pages and even from some results of my research, piping to script should be done like that
myscript.sh has this
So each time I have some log from sourcehost, myscript is triggered. The problem is with what is appended to logfile. I have only empty lines. In directfile I have correct log lines.
With different tries, I changed the exec part to
and after the change, logfile has correct log lines.
I read about stdin/stdout/stderr redirection when piping and using exec, but my different tries were not successful.
So I am searching for any idea what is happening here.
Thanks,
K.
Playing with syslog recently, I found a strange behaviour at some point and I am looking for some explanation.
From man pages and even from some results of my research, piping to script should be done like that
Code:
+sourcehost
*.* |exec /usr/local/sbin/myscript.sh
*.* /var/log/directfile
myscript.sh has this
Code:
#!/bin/sh
echo $* >> /tmp/logfile
So each time I have some log from sourcehost, myscript is triggered. The problem is with what is appended to logfile. I have only empty lines. In directfile I have correct log lines.
With different tries, I changed the exec part to
Code:
*.* |exec awk 'lf="/tmp/logfile"; {print $0 >> lf }'
I read about stdin/stdout/stderr redirection when piping and using exec, but my different tries were not successful.
So I am searching for any idea what is happening here.
Thanks,
K.