[GH-ISSUE #522] Option to use script instead of ttyrec #131

Closed
opened 2026-05-07 00:19:17 +02:00 by BreizhHardware · 3 comments

Originally created by @DenisBY on GitHub (Jan 30, 2025).
Original GitHub issue: https://github.com/ovh/the-bastion/issues/522

Is there a way to use script command instead of ttyrec? Or is there a way to convert a record into "plaintext"?

Originally created by @DenisBY on GitHub (Jan 30, 2025). Original GitHub issue: https://github.com/ovh/the-bastion/issues/522 Is there a way to use `script` command instead of `ttyrec`? Or is there a way to convert a record into "plaintext"?
Author
Owner

@speed47 commented on GitHub (Feb 4, 2025):

Hello,

The ttyrec program is actually a fork and a superset of script, and their output format is very similar. The main change is that for ttyrec, there is timing info added in the output file, so that it can be replayed "at the same pace" that the captured console.

With both programs, the entire console output is captured, i.e. plaintext, but also control codes, such as "move the cursor here", "change the background color to this", etc. If you cat the output files of script or ttyrexc, you'll see plaintext but also these non-printable control-codes. It is not trivial to convert these to "real" plaintext because you have to interpret all the control codes correctly to reproduce the actual output.

For example, if I type "helk" then "backspace" then "lo", on my console, "hello" will be displayed when I'm done, but in the output files of both script and ttyrec, this is what will be written: helk^H^[[Klo. So grepping for "hello" inside these files will not work, even if you would have expected it to work.

This even gets more complicated for programs using curses such as vim, where you can navigate in a file: a lot of control codes are used to control what the console displays, and there is no way, from what is displayed in the console, to know what is part of the preexisting file, and what is being typed by the person. In both cases, it just ends up on the screen.

Now, some solutions exists. You might want to have a look to IPBT (It's Playback Time), which is an advanced ttyrec player from the author of PuTTY: https://www.chiark.greenend.org.uk/~sgtatham/ipbt/ . It has the option of actually grepping for a string inside a ttyrec, and it does this by rendering each "frame" in-memory, then actually looking for the output in the emulated console. This would work with the "hello" example above. Modifying this program a bit might permit dumping all the strings that appear on all frames.

EDIT: it seems that the author recently added an "ipbt-dump" program that might be of interest for your use case: https://git.tartarus.org/?p=simon/ipbt.git;a=blob;f=doc/man-ipbt-dump.but;h=b2004cf0a925eac08c65448701ffd64e4f6a7eb3;hb=bc876eaf74939d3e7b255ac6c2d10c8d8f5fe276

<!-- gh-comment-id:2633414146 --> @speed47 commented on GitHub (Feb 4, 2025): Hello, The `ttyrec` program is actually a fork and a superset of `script`, and their output format is very similar. The main change is that for `ttyrec`, there is timing info added in the output file, so that it can be replayed "at the same pace" that the captured console. With both programs, the entire console output is captured, i.e. plaintext, but also control codes, such as "move the cursor here", "change the background color to this", etc. If you `cat` the output files of `script` or `ttyrexc`, you'll see plaintext but also these non-printable control-codes. It is not trivial to convert these to "real" plaintext because you have to interpret all the control codes correctly to reproduce the actual output. For example, if I type "helk" then "backspace" then "lo", on my console, "hello" will be displayed when I'm done, but in the output files of both `script` and `ttyrec`, this is what will be written: `helk^H^[[Klo`. So grepping for "hello" inside these files will not work, even if you would have expected it to work. This even gets more complicated for programs using `curses` such as `vim`, where you can navigate in a file: a lot of control codes are used to control what the console displays, and there is no way, from what is displayed in the console, to know what is part of the preexisting file, and what is being typed by the person. In both cases, it just ends up on the screen. Now, some solutions exists. You might want to have a look to IPBT (It's Playback Time), which is an advanced ttyrec player from the author of PuTTY: https://www.chiark.greenend.org.uk/~sgtatham/ipbt/ . It has the option of actually grepping for a string inside a ttyrec, and it does this by rendering each "frame" in-memory, then actually looking for the output in the emulated console. This would work with the "hello" example above. Modifying this program a bit might permit dumping all the strings that appear on all frames. EDIT: it seems that the author recently added an "ipbt-dump" program that might be of interest for your use case: https://git.tartarus.org/?p=simon/ipbt.git;a=blob;f=doc/man-ipbt-dump.but;h=b2004cf0a925eac08c65448701ffd64e4f6a7eb3;hb=bc876eaf74939d3e7b255ac6c2d10c8d8f5fe276
Author
Owner

@DenisBY commented on GitHub (Feb 4, 2025):

Thank you for such detailed explanation!

<!-- gh-comment-id:2634501134 --> @DenisBY commented on GitHub (Feb 4, 2025): Thank you for such detailed explanation!
Author
Owner
<!-- gh-comment-id:3281390527 --> @speed47 commented on GitHub (Sep 11, 2025): Added as FAQ https://ovh.github.io/the-bastion/faq.html#can-the-bastion-record-sessions-with-script-or-in-plaintext-format-instead-of-ttyrec
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/the-bastion#131
No description provided.