1

I am very new to irssi (and IRC in general), and I have the need to log only the last N number of lines from irssi to a text file, but I can't find any information on how to do something like that - be it with built in features or a script.

What I want to do is overlay the last 10 or so lines of chat on a video in real time. To do this I can use and ffmpeg filter which updates when a text file is changed on disk. Therefore what I want to do is continuously write the most recent 10 lines from an active irssi session to a text file.

How could I do that?

2
  • Is the problem getting the log or is it getting 10 lines only? If the latter,meould parsing the file to keep only 10 lines be acceptable?
    – terdon
    Nov 5 '14 at 1:05
  • I think logging the chat is easy enough with irssi, but I want only 10 lines in a text file because I'll be using ffmpeg to read said file and overlay it on a video in real time, so I need there to be at most 10 or so lines. I think it would be ideal to have irssi just put 10 lines in a file rather than have a script sitting there and continuously taking 10 lines out of the full log. Nov 5 '14 at 1:08
1

If you run the output of irssi to the tail command you can get the last X number of lines, ex. cmd | tail -10.

Example

Using the seq command as a stand in for your irssi command. The seq command will generate a sequence of numbers from 1-100, in the example below.

$ seq 100 | tail -10
91
92
93
94
95
96
97
98
99
100

To dump it to a file, /var/log/mychat.log, you can redirect the output from tail using >.

$ seq 100 | tail -10 > afile
$ more afile 
91
92
93
94
95
96
97
98
99
100

If you'd like to see the output while writing it to the log file, you can use the tee command instead of the file redirect, >.

$ seq 100 | tail -10 | tee afile
91
92
93
94
95
96
97
98
99
100
6
  • Your last example describes basically what I want, however when I run irssi | tail -10 | tee test.txt, nothing happens. The terminal hangs and irssi never appears. Nov 6 '14 at 2:37
  • @CameronBall - I don't think you can do that with irssi, it would need to be writing to a log file and you could run the above against that log file.
    – slm
    Nov 6 '14 at 2:53
  • See the logging section for away in the docs: irssi.org/documentation/startup#c8. They show how you can log when you're away to a file, you could then tail that log file.
    – slm
    Nov 6 '14 at 2:57
  • That's not really what I want to do. I need to get the last 10 or so lines from irssi in a text file which ffmpeg is reading to overlay on a video. So it needs to be continuously updated. Nov 6 '14 at 3:39
  • @CameronBall - perhaps you can update your Q then, since you're not giving us really enough to go on here. Try and be as thorough about what you're trying to accomplish.
    – slm
    Nov 6 '14 at 3:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.