Last active
December 22, 2015 17:29
-
-
Save hagun/6506214 to your computer and use it in GitHub Desktop.
stdin에서 line을 읽어서 netcat으로 원격지에 tcp 전송
첫번째 parameter를 이용해서 log format을 수정
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| while read LINE; do | |
| echo "$1:{${LINE}}" | nc 192.168.161.117 3333 | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| stream=`nc 192.168.161.117 3333` | |
| while read LINE; do | |
| echo "$1:{${LINE}}" >> $stream | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ "$#" -ne 2 ] || ! [ -f "$2" ]; then | |
| echo "Usage: $0 SERVICENAME FILENAME" >&2 | |
| exit 1 | |
| fi | |
| tail -n 1 -F $2 | awk -W interactive '{print "'$1':{",$0,"}"}' | while read LINE; do | |
| echo "${LINE}" >> $stream || stream=`nc 192.168.161.117 3333` | |
| done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
v3에서는 tail을 내부적으로 처리하고, 사용법 노출, awk를 이용한 처리 등을 추가