13

Here's my situation: I open terminal and run program which displays live feed in terminal (text) what changes every second. Only "Enter" key can be used while this program is running (it exits that program). So you can't type anything else into console.

I would like to write that terminal contents into a file, like after every second.

How do I do it? By opening 2nd console and using some command? Can't get it work with setterm -dump command.

2
  • 1
    Hm, which application is this? If you haven't checked well, you should make sure if the application has an option to save the ouput somewhere.
    – Severo Raz
    Mar 26, 2011 at 9:25
  • Did check that. It doesn't. Otherwise I wouldn't have this problem. Program is live-f1, launchpad.net/live-f1
    – Gustav
    Mar 26, 2011 at 10:28

3 Answers 3

17

You can pipe your output to the tee program (description):

my_program ... | tee my_program.log

This will show the ouput on the terminal, but also write it to the file my_program.log

2
  • Same result like with 1st answer. :/
    – Gustav
    Mar 26, 2011 at 8:20
  • 1
    The screenshot you posted looks like it has a lot of terminal escape sequences in it. From the launchpad info, it uses ncurses (I downloaded the source with bzr branch lp:live-f1, then went looking in the README). Can you run the program without colors by setting TERM to dumb (export TERM=dumb)? The source also has a TODO file, noting on the wishlist to keep a history of the drivers. Maybe you can contact the developers to see what they're planning or if they have a way for you to save results.
    – steabert
    Mar 26, 2011 at 11:19
12

When you are executing your command from terminal instead of seeing the output on your console you can redirect it straight to a file. While the program runs your the output is going to be written to the file. An example lets say you want to write the contents of your folder with an ls command to a file called list.txt

ls > list.txt

The > operator redirects your output according to your needs.

3
  • Thx, this works but partly. Content should be HTML, but when I open the file, it's something like this (snip from the file): VETTEL[21G(B[m[39;49m. Program's name is "live-f1". live-f1 > live_f1_dump.log
    – Gustav
    Mar 26, 2011 at 8:19
  • @Gustav you mean that in console it prints html and in the file the above lines?
    – topless
    Mar 26, 2011 at 9:02
  • Yes. This is what I get when I run your suggested command: upload.ee/image/1223166/ss_01.png. My goal is to get Formula 1 drivers' positions from live-f1 feed into a file. I got it work last year by running live-f1 program in 1st terminal, then firing up 2nd terminal and using some command what captured 1st terminal screen and saved it to a file (copy from last year's file: upload.ee/download/1223347/0b6545ce227661452c8/html.log). Command was something like that: tty "1st terminal pointer" "filename". Possible that it was something else that "tty" what I used for that.
    – Gustav
    Mar 26, 2011 at 10:34
2

Try using the script command. Unfortunately, it puts a lot of control character gobbledegook in the transcript. However, if you see this link at the NCSSM CS Site you will find an imperfect but pretty good solution to the problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .