After some time, I finally got socat
to behave in the same way as putty
, using:
stty -F /dev/ttyS2 115200 cs8 ixoff
socat $(tty),raw,echo=0,escape=0x03,nonblock /dev/ttyS2
stty sane
I would also like to log the conversation to a log file.
EDIT:
I figured out a way how to do it, (but I think it's a kludge), so I answered my own question - and it is a valid answer by stack overflow standards.
(my first approach was not correct, so I modify)
I have never used
socat
, butif it hasas I see with-v log.txt
option I have a possible solution for you-v
option it prints the result also to stderr.I assume You want to have the log file sent into log.txt, cut the first 10 lines and all the
\r
characters removed. On a bash which supports process substitution it can be done like this:(Mind the space between the two
>
marks!!!)This will create a process and
>(...)
returns a file like/dev/fd/68
and redirects thestderr
to it. Actually this is a pipe to the process specified inside the brackets (awk
). So the text goes through awk and its output is written intolog.txt
.As You mentioned, You do not have awk this can be solved using sed (or
tail
andtr
pipe but it needs an extra process).(Mind the space between the two
>
marks!!!)It seems cygwin does not support this, but it worked on a fairly old RedHat Linux.
Actually You can also use
-lf
(I'm not sure that this prints everything You need. Maybe-v
if a better choice...):So the original approach also can work:
I hope this helps!