0

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?

AdminBee
  • 22,803

1 Answers1

0

So I have found this works:

cat somemultilinefile | while read -r line; do echo "$line" | nc -w0 -u syslog_server 514 ; done

Seems that there should be a better way but this gets it done.