I am trying to send text log files to my remote syslog server. I need to be able to take a file, and for each line in that file (newline as the separator), send that line via netcat
to a remote syslog host. I don't want the whole file to be sent in one connection as it will show in syslog as one massive blob. Also, I need to be able to execute this from the command line. I can't create a script and execute it.
For example, this sends the whole file in one blob (not what I want):
cat somemultilinefile | nc -u -w 0 syslogip 514
I have tried awk
with system()
and xargs
, but have not found a combination that works. Any ideas?