리눅스 로그 > 윈도우 TCP/IP통신에서 CRLF적용 문제

kysu5095의 이미지

안녕하세요. 며칠전 리눅스 환경에서 윈도우 환경으로 TCP/IP로 시리얼 통신하는 과정에서
LF(Linux) <-> CRLF(Windows) 차이로 인해 질문했었습니다.
아직도 해당문제를 해결하지 못하여 다시한번 질문드립니다ㅠ

현재 작업순서는 리눅스환경의 보드의 /var/log/messages를 윈도우환경으로 TCP/IP로 통신하여
윈도우에서 해당 로그를 확인하는 작업입니다.

시리얼을 받는 윈도우 환경에서 수정을 할 수 없는 상황이어서 보내는쪽인 리눅스환경에서 수정을 해야할거 같은데
도저히 방법이 떠오르지 않습니다ㅠ
추가로 TCP/IP 소스는 건드리지 않는선에서 해결해야 하기때문에 더 문제입니다

messages파일에 \n에 \r만 추가하면 될것같은데 생각대로 되질 않네요,,,
힌트 좀 부탁드리겠습니다,,,,

=======================추가==========================
sed 라는 명령어로 messages의 형식을 CRLF로 바꾼 후 통신할 수 있는건가요?

bushi의 이미지

이전 글에 댓글을 남겼는데,
1. 댓글이 뭔 소린지 잘 이해가 안가고,
2. 얼마전에 remserial 질문한 분과 같은 분이면,
remserial 실행 때 -s 옵션으로 icrnl 이나 ocrnl 줘 보세요.

kysu5095의 이미지

기존 remserial을 실행할때 ./remserial -p 23000 -s "115200 raw" -d /var/log/messages &로 했던것을
./remserial -p 23000 -s "115200 raw icrnl" -d /var/log/messages & 과
./remserial -p 23000 -s "115200 raw ocrnl" -d /var/log/messages & 둘 다 해보았지만 아직도 LF방식으로만
출력되고 있습니다ㅠ

chanik의 이미지

remserial은 모르지만 stty 옵션에 준해 생각해보면,
ocrnl은 CR -> LF 변환해주는 옵션이겠고
onlcr이 LF -> CRLF 해주는 옵션이겠네요

https://linux.die.net/man/1/stty

* [-]onlcr
    translate newline to carriage return-newline 

이걸로 안 되면, 아래와 같이 process substitition으로 해결될수도 있겠습니다.

./remserial -p 23000 -s "115200 raw" -d <(sed 's/$/\r/' /var/log/messages) &
chanik의 이미지

로그파일을 telnet 클라이언트에게 공유하는 것은 nc를 써서 아래와 같은 식으로 해도 되지 않나요? 로그파일을 처음부터 덤프하되 파일 끝에 도달해도 종료하지 말고 이후 추가되는 내용도 클라이언트에게 계속 보내는 식이며, nc의 -C 옵션이 stty onlcr 역할을 해줍니다.

$ tail -n +1 -f /var/log/messages | nc -p 23000 -l -k -C > /dev/null

Anti-Lock의 이미지

1. 리눅스에서 로그를 어떻게(프로그램? 옵션? 프로토콜?) 송신합니까?
2. 윈도우에서 해당로그를 어떻게(프로그램? 옵션?) 확인하나요?

그 설명이 없는데... 누가 해결해 줄수 있겠습니까?

나빌레라의 이미지

\n을 \r\n으로 바꾸면 됩니다.

s/\n/\r\n/g

----------------------
얇은 사 하이얀 고깔은 고이 접어서 나빌레라

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.