Click to See Complete Forum and Search --> : serial output to screen and file?


tecknophreak
08-14-2003, 11:07 AM
I've got a logging function on another cpu which sends out some info about 50 chars every 10 seconds or so.

I've thought I'd give

cat /dev/ttyS0 > cpuOutput

a try, which it did, I liked that. But I also want to see what's going into that file in real time. Is there a command that'll do that?

<this may be more suitable in another forum, but i couldn't think of which one>

kshim5
08-14-2003, 11:16 AM
You can probably echo the input as it is being written to the file one character at a time then when you reach <eol> move to the next row.

ph34r
08-14-2003, 11:43 AM
Try

tail -f /dev/ttyS0 > cpuOutput &
tail -f cpuOutput


The & puts the process in the background, and then you can tail the file it is creating.

tecknophreak
08-14-2003, 12:05 PM
I'm guessing,
tail /dev/ttyS0 > cpuOutput

does the same as:
cat /dev/ttyS0 > cpuOutput

When I do just

cat /dev/ttyS0

It outputs the data when it comes in, automatically, this way I don't have to do any work, i.e. tail .....

I just thought there would be something which would be able to split the data coming in and output it to both the fp and a file.

Stuka
08-14-2003, 12:31 PM
man tee

cat /dev/ttyS0 | tee cpuOutput

should work, if I read the man page correctly (quick scan). tee echoes stdin to stdout and a file.

tecknophreak
08-14-2003, 01:15 PM
:D Excellent!