0

I use specific program named lirc_monitor is used to monitoring pressed keys on the embedded ARM device. I wanna redirect all output to file but I'm stuck I spended ~2 hours to check every option what I found and... nothing! file all the time empty..

Maybe someone has any ideas? to verify this problem. Thank you.

-sh-3.2# lirc_monitor 
{lirc monitor}: 0000000000000000 00 CURSOR_DOWN MTK_IR

{lirc monitor}: 0000000000000000 00 CURSOR_DOWN MTK_IR

{lirc monitor}: 0000000000000000 00 CURSOR_DOWN MTK_IR

{lirc monitor}: 0000000000000000 00 CURSOR_DOWN MTK_IR

{lirc monitor}: 0000000000000000 00 CURSOR_DOWN MTK_IR

{lirc monitor}: 0000000000000000 00 CURSOR_DOWN MTK_IR
jasko887
  • 29
  • 4
  • Have you tested `lirc_monitor > log 2>&1` ? – Gilles Quénot Apr 16 '23 at 23:52
  • Yep still empty. – jasko887 Apr 17 '23 at 00:01
  • You made sure that you have permission to write to the file? – kojow7 Apr 17 '23 at 00:06
  • Yes ofc I'm root and save to /tmp. – jasko887 Apr 17 '23 at 00:08
  • 1
    Related Question https://stackoverflow.com/questions/76002223/lirc-monitor-how-to-track-process-data-output-in-loop – ti7 Apr 17 '23 at 02:06
  • 1
    perhaps it's using `wall` or directly writing to your terminal from another process – ti7 Apr 17 '23 at 02:21
  • Can I do something about it? – jasko887 Apr 17 '23 at 08:37
  • Can you please clarify how this is different from your earlier question https://stackoverflow.com/questions/76002223/lirc-monitor-how-to-track-process-data-output-in-loop? – tripleee Apr 17 '23 at 09:25
  • No, that's the origin of the problem, I'm trying to find the cause. Script from this thread not working like should be. – jasko887 Apr 17 '23 at 15:27
  • Ok I got help on russian forum this is translation "PS: I got burned and I made a smarter patch - now lirc_monitor clears buffers after each line by calling fflush(). Patched lirc_monitor_fflush, which can be parsed normally with a pipe:" So I got patched binary file and I can without any problems redirect to log. – jasko887 Apr 17 '23 at 15:55

4 Answers4

0

lirc_monitor normally outputs to stderr rather than stdout, so you need 2> to redirect its output. Eg:

lirc_monitor 2> lirc_monitor.log
Chris Dodd
  • 119,907
  • 13
  • 134
  • 226
  • In this case I see output in console after pressed button but file empty https://i.imgur.com/9E7Zner.png – jasko887 Apr 16 '23 at 23:56
0

Ok I got help on russian forum this is translation:

"PS: I got burned and I made a smarter patch - now lirc_monitor clears buffers after each line by calling fflush(). Patched lirc_monitor_fflush, which can be parsed normally with a pipe:"

So I got patched binary file and I can without any problems redirect to log.

Problem resolved.

jasko887
  • 29
  • 4
-1

You can redirect the output stream with >

lirc_monitor > output.log

For more convenience, use tee, which will write to both the file and stdout

lirc_monitor | tee -a output.log

If > doesn't redirect the output (you still see the output with simply >), it's going to stderr, and you can redirect it with 2> filename directly or 2>&1 to join the stderr to stdout stream

lirc_monitor 2>&1 | tee -a output.log
ti7
  • 16,375
  • 6
  • 40
  • 68
-1

Have you tried the using nohup

nohup lrc_monitor > lrc_monitor.log &

nohup - ignores hang up, probably needed because lrc_monitor seem to keep running until you stop it manually.

> lrc_monitor.log - tells the terminal to log the output to a file called lrc_monitor.log

& - tells the terminal to run your command in the background

Shirofuji
  • 36
  • 8