I must be getting old. I was always taught to use the
script typescript
command when doing anything important at the command line.
No-one seems to even know of its existence today.
I recently suggested to @Rosika tha tshe use it and she tried and came back with this
the output of the “typescript”-file is not particularly well-readable. But it can be improved to some extent by issuing the command col -bx < typescript > cleanedfile The resulting file certainly provides better results when using less.
And @Rosika is right… the output of script is barely readable in its ‘raw’ form.
Here is a short segment of one of my script files viewed with less
Script started on 2022-07-14 21:27:36+10:00 [TERM="xterm-256color" TTY="/dev/pts/9" COLUMNS="78" LINES="26"] ESC[?2004h[nevj@trinity Goldboot]$ cESC[Kargo build ESC[?2004l^MESC[0mESC[0mESC[1mESC[32m CompilingESC[0m goldboot v0.0.1 (/common/Goldboot/goldboot) ESC[0mESC[0mESC[1mESC[36m BuildingESC[0m [=======================> ] 389/393: goldboot ^MESC[KESC[0mESC[1mESC[38;5;9merror[E0433]ESC[0mEESC[0mESC[1m: failed to resolve: use of undeclared type `TemplateMetadata`ESC[0m ESC[0m ESC[0mESC[0mESC[1mESC[38;5;12m--> ESC[0mESC[0mgoldboot/src/cmd/init.rs:110:45ESC[0m ESC[0m ESC[0mESC[0mESC[1mESC[38;5;12m|ESC[0m ESC[0mESC[1mESC[38;5;12m110ESC[0mESC[0m ESC[0mESC[0mESC[1mESC[38;5;12m| ESC[0mESC[0m let templates: Vec = TemplateMetadata::load()ESC[0m ESC[0m ESC[0mESC[0mESC[1mESC[38;5;12m| ESC[0mESC[0m ESC[0mESC[0mESC[1mESC[38;5;9m^^^^^^^^^^^^^^^^ESC[0mESC[0m ESC[0mESC[0mESC[1mESC[38;5;9muse of undeclared type `TemplateMetadata`ESC[0m ESC[0mESC[0mESC[1mESC[36m BuildingESC[0m [=======================> ] 389/393: goldboot ^MESC[KESC[0mESC[1mESC[38;5;9merror[E0433]ESC[0mEESC[0mESC[1m: failed to resolve: use of undeclared type `TemplateBase`ESC[0m (END)
If I clean it using @Rosika 's method I get
Script started on 2022-07-14 21:27:36+10:00 [TERM="xterm-256color" TTY="/dev/pts/9" COLUMNS="78" LINES="26"] ?2004h[nevj@trinity Goldboot]$ cKargo build 0m0m1m32m Compiling0m goldboot v0.0.1 (/common/Goldboot/goldboot) K0m1m38;5;9merror[E0433]0m0m1m:=failed=to=resolve:]use9of9undeclaredttype `TemplateMetadata`0m 0m 0m0m1m38;5;12m--> 0m0mgoldboot/src/cmd/init.rs:110:450m 0m 0m0m1m38;5;12m|0m 0m1m38;5;12m1100m0m 0m0m1m38;5;12m| 0m0m let templates: Vec = TemplateMetadata::load()0m 0m 0m0m1m38;5;12m| 0m0m 0m0m1m38;5;9m^^^^^^^^^^^^^^^^0m0m 0m0m1m38;5;9muse of undeclared type `TemplateMetadata`0m K0m1m38;5;9merror[E0433]0m0m1m:=failed=to=resolve:]use9of9undeclaredttype `TemplateBase`0m
which is certainly better but not perfect.
The typescript file should appear as follows
Script started on 2022-07-14 21:27:36+10:00 [TERM="xterm-256color" TTY="/dev/pts/9" COLUMNS="78" LINES="26"] [nevj@trinity Goldboot]$ cargo build Compiling goldboot v0.0.1 (/common/Goldboot/goldboot) error[E0433]: failed to resolve: use of undeclared type `TemplateMetadata` --> goldboot/src/cmd/init.rs:110:45 | 110 | let templates: Vec = TemplateMetadata::load() | ^^^^^^^^^^^^^^^^ use of undeclared type `TemplateMetadata` error[E0433]: failed to resolve: use of undeclared type `TemplateBase`
It is output from the rustc compiler.
After lots of looking, I have found several better methods
First, there is a parameter -R
available for less
which filters out most of the control characters, and preserves colour. The output from less -R typescript
looks as follows
Almost perfect, except it fails to remove ^M
So second attempt… the only program that will remove ^M
is more
. It does not have the -R
argument that less
has, so we need to use cat
to do what -R
was doing,
cat typescript | more
leads to
so we finally get it right.
Does anyone have a better method?
And why is script not more widely used?
And has anyone tried typescript2txt
command?