2

While looking into a shell redirection problem, I found a couple of answers that pointed me to the script command. As I understand it, script just records in- and output of the terminal, and allows me to read that from a file later. It covers some edge cases that don't work with regular bash redirection (2>&1 > /tmp/log), but, from the man page:

Certain interactive commands, such as vi(1), create garbage in the typescript file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal.

Similarly, also from the man page and probably related:

BUGS
Script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects.

Is there a better way to record an interactive terminal program that also catches output from sub-processes, but doesn't suffer from these problems? Are there alternatives to script?

Related questions: bash redirection, stdout+stderr does not redirect everything

migrated from stackoverflow.com Aug 2 '15 at 1:17

This question came from our site for professional and enthusiast programmers.

  • What exactly are you looking for? You can postprocess the output to clean it up, although lamentably there is not a standard utility which does this. – tripleee Aug 1 '15 at 17:38
  • Basically I'm looking for a tool that does exactly that which script does, but for interactive programs, in particular the changes on the terminal. That way I can easily record an entire session, including any changes I make to files (such as configuration files or gdb output), which could be really useful to create tutorials or replayable live demonstrations. – Rens van der Heijden Aug 1 '15 at 17:49
  • script is all about interactive programs. What it is not about is I/O that is received from or delivered to anything other than the standard streams. Moreover, it is a general-purpose program -- it records, but it does not interpret. If you need more than that then it probably needs to be specifically tailored to your particular use. – John Bollinger Aug 1 '15 at 17:57
  • Software recommendations are off-topic on Stack Overflow. – chepner Aug 1 '15 at 18:17
  • see stackoverflow.com/questions/15698590/… and serverfault.com/questions/470755/…... I would also suggest posting your question on the Unix & Linux stack exchange, as your question is not specifically programming related. Also, check out ttyrec -- 0xcc.net/ttyrec/index.html.en – Barton Chittenden Aug 1 '15 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.