Who uses the 'script' command?

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?

1 Like

Hi Neville, :wave:

thanks for the interesting topic.

I just tried all of your solutions on my Debian10 VM.
Interestingly enough just cat typescript yielded the best reults in my test.

I ran a test this way:

script

and then 3 commands: cal, pwd, whoami; then ctrl + D.

Here are the results:

cat typescript
Script started on 2022-07-15 14:08:41+02:00 [TERM="xterm-256color" TTY="/dev/pts/0" COLUMNS="93" LINES="52"]
Willkommen zu fish, der freundlichen interaktiven Shell
rosika2@debian ~/prov_kgw> cal
     Juli 2022        
So Mo Di Mi Do Fr Sa  
                1  2  
 3  4  5  6  7  8  9  
10 11 12 13 14 15 16  
17 18 19 20 21 22 23  
24 25 26 27 28 29 30  
31                    
rosika2@debian ~/prov_kgw> pwd
/home/rosika2/prov_kgw
rosika2@debian ~/prov_kgw> whoami
rosika2
rosika2@debian ~/prov_kgw> 

Script done on 2022-07-15 14:09:02+02:00 [COMMAND_EXIT_CODE="0"]

which seems rather good.

Here are the other commands:

less -R typescript :

cat typescript | more :

Here, I think commands 2 and 3 seem to be missing. :face_with_raised_eyebrow:

Even bat didn´t produce something nice.:

So your question

is certainly a valid one. :wink:

I´m also interested in what others might say.

Many greetings from Rosika :slightly_smiling_face:

1 Like

Thank you Rosika
It is quite clear that I did not test the various methods on sufficient different typescripts.
Or maybe your fish shell is different?

Your cat typescript preserved colour, but less -R did not, and cat|more lost lines as well as not preserving color.

Very strange… it needs a rethink.

I know one thing… the reason cat does a good job is that it leaves behind control characters. So does less -R but not all of them apparently.

We need to look further.
It looks like you were using fish shell. Can we eliminate that ?
Could you try again with bash? If shells differ, we are in trouble.
Regards
Neville

1 Like

Hi Neville, :wave:

Uh, I think some of the confusion arose from the fact that I posted the first output (cat) directly here as preformatted text whereas the others were screenshots. Sorry. :expressionless:

But you´re right: I usefd fish for all of that.
So here´s the output in bash (all screenshots this time):

cat typescript 

less -R typescript

cat typescript | more

bat typescript

Hmm, I guess readibility isn´t better here either. :thinking:

Many greetings.
Rosika :slightly_smiling_face:

1 Like

You are right. Your typescript file was a better test than mine
I just started this when I could hardly read the scripting of my rust compile job, so I used that … Bad choice.

All your tests preserve color.

I need to do a rethink. … but the conclusion at the moment seems to be… just use cat.
That is not very convenient for long files.
I cant imagine why cat | more loses lines? I want to look into that because cat | more is more convenient than cat.

Thank you for doing that all again. It is not the shell… we can forget that idea

By the way, there is a language called Typescript… dont confuse it with typescript files as made by script.

Regards
Neville

1 Like

Hi Neville, :wave:

thanks so much for your reply.

Oh, don´t say that. You certainly know much more about the topic than I do.
I just punched in three commands that entered my mind…,. that´s all. :blush:

O.K., it seems so, I think.

Right, that´s a real puzzler. Perhaps any of the other experts might have an idea?

You´re very welcome, Neville. :heart:

Thanks for the hint. I just looked it up in gedit and indeed found “TypeScript” as a language option. :wink:

Many greetings
Rosika :slightly_smiling_face:

1 Like

Well its even more of a puzzler now that I have looked at it
I have a file called debupdate20220216.out which is a Debian update script output. Here is what it looks like in vi ( which shows all the control characters)

vi debupdate20220216.out
Script started on 2022-02-16 20:34:03+11:00 [TERM="xterm-256color" TTY="/dev/pts/1" COLUMNS="80" LINES="24"]
^[[?2004hroot@trinity:/home/nevj# apt-get update^M
^[[?2004l^M^M0% [Working]^M            ^MHit:1 http://deb.debian.org/debian bullseye InRelease^M
^M0% [Connected to debian.map.fastly.net (151.101.30.132)]^M                                                        ^MHit:2 http://deb.debian.org/debian bullseye-updates InRelease^M
^M0% [Connected to debian.map.fastly.net (151.101.30.132)]^M                                                        ^MHit:3 http://deb.debian.org/debian bullseye-backports InRelease^M
^M                                                        ^M0% [Waiting for headers]^M0% [Waiting for headers]^M0% [Waiting for headers]^M0% [Waiting for headers]^M                        ^MHit:4 https://deb.debian.org/debian-security bullseye-security InRelease^M
@                                                                               @                                                                               @                                                                               @                                                                               @                                                                               @                                                                               @                                                                               @  
      ^M                                                        ^M0% [Waiting for headers]^M0% [Waiting for headers]^M0% [Waiting for headers]^M0% [Waiting for headers]^M                        ^MHit:4 https://deb.debian.org/debian-security bullseye-security InRelease^M
^M                        ^M0% [Working]^M20% [Working]^M             ^M^MReading package lists... 0%^M^MReading package lists... 0%^M^MReading package lists... 0%^M^MReading package lists... 54%^M^MReading package lists... 54%^M^MReading package lists... 90%^M^MReading package lists... 90%^M^M                                               
......                                                 

Thats just the first bit… it has some ^[ and ^M characters

So lets cat that to a file and see what cat leaves behind

nevj@trinity:~$ cat debupdate20220216.out > junk
nevj@trinity:~$ cmp debupdate20220216.out junk

Nothing is left behind , they are identical

So how does cat cause more to lose lines?
It doesnt. Cat does nothing to that script file, but more has a problem with the file itself

nevj@trinity:~$ cat debupdate20220216.out
Script started on 2022-02-16 20:34:03+11:00 [TERM="xterm-256color" TTY="/dev/pts/1" COLUMNS="80" LINES="24"]
root@trinity:/home/nevj# apt-get update
Hit:1 http://deb.debian.org/debian bullseye InRelease
Hit:2 http://deb.debian.org/debian bullseye-updates InRelease
Hit:3 http://deb.debian.org/debian bullseye-backports InRelease
Hit:4 https://deb.debian.org/debian-security bullseye-security InRelease
Reading package lists... Done
root@trinity:/home/nevj# apt-get upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  linux-image-amd64
The following packages will be upgraded:
  firefox-esr libcryptsetup12 libexpat1 libexpat1-dev libsmbclient
  libwbclient0 samba-libs thunderbird yt-dlp
9 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/118 MB of archives.
After this operation, 13.3 kB disk space will be freed.
Do you want to continue? [Y/n] y
Reading changelogs... Done
(Reading database ... 382605 files and directories currently installed.)
Preparing to unpack .../0-libsmbclient_2%3a4.13.13+dfsg-1~deb11u3_amd64.deb ...
Unpacking libsmbclient:amd64 (2:4.13.13+dfsg-1~deb11u3) over (2:4.13.13+dfsg-1~deb11u2) ...
Preparing to unpack .../1-samba-libs_2%3a4.13.13+dfsg-1~deb11u3_amd64.deb ...
Unpacking samba-libs:amd64 (2:4.13.13+dfsg-1~deb11u3) over (2:4.13.13+dfsg-1~deb11u2) ...
Preparing to unpack .../2-libwbclient0_2%3a4.13.13+dfsg-1~deb11u3_amd64.deb ...
Unpacking libwbclient0:amd64 (2:4.13.13+dfsg-1~deb11u3) over (2:4.13.13+dfsg-1~deb11u2) ...
Preparing to unpack .../3-firefox-esr_91.6.0esr-1~deb11u1_amd64.deb ...
Leaving 'diversion of /usr/bin/firefox to /usr/bin/firefox.real by firefox-esr'
Unpacking firefox-esr (91.6.0esr-1~deb11u1) over (91.5.0esr-1~deb11u1) ...
Preparing to unpack .../4-libcryptsetup12_2%3a2.3.7-1+deb11u1_amd64.deb ...
Unpacking libcryptsetup12:amd64 (2:2.3.7-1+deb11u1) over (2:2.3.5-1) ...
Preparing to unpack .../5-libexpat1-dev_2.2.10-2+deb11u1_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.2.10-2+deb11u1) over (2.2.10-2) ...
Preparing to unpack .../6-libexpat1_2.2.10-2+deb11u1_amd64.deb ...
Unpacking libexpat1:amd64 (2.2.10-2+deb11u1) over (2.2.10-2) ...
......

but

more debupdate20220216.out
Script started on 2022-02-16 20:34:03+11:00 [TERM="xterm-256color" TTY="/dev/pts
/1" COLUMNS="80" LINES="24"]
root@trinity:/home/nevj# apt-get update








root@trinity:/home/nevj# apt-get upgrade




The following packages have been kept back:
  linux-image-amd64
The following packages will be upgraded:
  firefox-esr libcryptsetup12 libexpat1 libexpat1-dev libsmbclient
  libwbclient0 samba-libs thunderbird yt-dlp
9 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/118 MB of archives.
After this operation, 13.3 kB disk space will be freed.
Do you want to continue? [Y/n] y
Reading changelogs... 10%

Preparing to unpack .../0-libsmbclient_2%3a4.13.13+dfsg-1~deb11u3_amd64.deb ...
Unpacking libsmbclient:amd64 (2:4.13.13+dfsg-1~deb11u3) over (2:4.13.13+dfsg-1~d
eb11u2) ...
Preparing to unpack .../1-samba-libs_2%3a4.13.13+dfsg-1~deb11u3_amd64.deb ...
Unpacking samba-libs:amd64 (2:4.13.13+dfsg-1~deb11u3) over (2:4.13.13+dfsg-1~deb
11u2) ...
Preparing to unpack .../2-libwbclient0_2%3a4.13.13+dfsg-1~deb11u3_amd64.deb ...
Unpacking libwbclient0:amd64 (2:4.13.13+dfsg-1~deb11u3) over (2:4.13.13+dfsg-1~d
eb11u2) ...
......

More has lost those lines that begin Hit:1 http: …
What is special about those lines?
Well, looking back at the vi view of the file … I cant see anything special about them at all.
Checking with od -a to see if vi suppressed some control characters I find the lines beginning ^[[ in vi have ESC[ in od -a but otherwise everything is the same. Some of those lines are very long and dont show in vi… i doubt if that is the issue

A complete mystery .
Can anyone enlighten me as to why more loses lines from this script file?

PS. There is a problem . The vi output does not even display properly on ItsFOSS. What I copy from the vi scrren into my edit space does not all translate to the displayed post?
I will have to find a tiny script file that shows the same behaviour. FOSS should be able to display anything I copy from a vi screen, even with ^M and ^[ characters.

1 Like

I have a solution, but not an understanding

There is a really good article on script output here

It contains a perl script called script-declutter which is specially written to clean up output from script.

When I run script-declutter on my test file I get

./bin/script-declutter debupdate20220216.out | more
Script started on 2022-02-16 20:34:03+11:00 [TERM="xterm-256color" TTY="/dev/pts
/1" COLUMNS="80" LINES="24"]
root@trinity:/home/nevj# apt-get update
0% [Working]            Hit:1 http://deb.debian.org/debian bullseye InRel
ease
0% [Connected to debian.map.fastly.net (151.101.30.132)]                        
                                Hit:2 http://deb.debian.org/debian bullseye-upda
tes InRelease
0% [Connected to debian.map.fastly.net (151.101.30.132)]                        
                                Hit:3 http://deb.debian.org/debian bullseye-back
ports InRelease
                                                        0% [Waiting for headers]
0% [Waiting for headers]0% [Waiting for headers]0% [Waiting for headers]        
                Hit:4 https://deb.debian.org/debian-security bullseye-security I
nRelease
                        0% [Working]20% [Working]             Reading package li
sts... 0%Reading package lists... 0%Reading package lists... 0%Reading package l
ists... 54%Reading package lists... 54%Reading package lists... 90%Reading packa
ge lists... 90%Reading package lists... 90%Reading package lists... 90%Reading p
ackage lists... 91%Reading package lists... 91%Reading package lists... 91%Readi
ng package lists... 91%Reading package lists... 92%Reading package lists... 92%R
eading package lists... 93%Reading package lists... 93%Reading package lists... 
93%Reading package lists... 93%Reading package lists... 93%Reading package lists
........

That seems reasonable - it has not lost any lines , and I can page it with more or less.
Not perfect, not as good as cat, but readable and pageable

There are a number of other dedicated solutions

  • dewtall’s script - another perl script
  • ansifilter - a C++ program
  • typescript2txt - a C++ program
    These bear looking at.
1 Like

Hi Neville, :wave:

you´ve put so much time and effort into solving this problem. Thanks a lot for that.

O.K., that´s strange. :thinking:
Thanks however for the hint towards od, which I never knew before. I´ll look into it. :blush:

Oh, thanks also for the link dealing with “script-declutter”. Must read it first.

However my internet conenction (mobile / AldiTalk) has been really bad for the past three days.
Obviously there was some maintenance work going on (cell tower or junction box) which should´ve come to an end yesterday. Alas even today download speeds seem to be far away from what 4G promises. :frowning_face:

Thanks a lot and many greetings.
Rosika :slightly_smiling_face:

1 Like

@nevj:

Hi Neville, :wave:

After looking around in ubuntuusers I came across the following alternative:

Instead of script you could use the following command:

bash -i 2>&1 | tee teetypescript

So basically making use of an interactive shell I started a session with the 3 commands already used previously. Then “ctrl + D” to end the session and then I took a look at
teetypescript with cat.

This is how it looks like:

teetypescript

It seems to have gotten rid of any ANSI-escape-sequences and stuff like that. :smiley:

But my example was a simple one . It´d be interesting to see how it works with you. :wink:

Many greetings from Rosika :slightly_smiling_face:

  1. It has its issues and pitfalls. It’s not a 100% compatible with every single operation one might want to do inside a shell. I have read a couple of users’ accounts on this topic, but I cannot find the source, anymore. I’ll add the link to that, if I ever re-find the source.
  2. It’s not a solution. It’s a workaround. Classic Unix shell designs are hell. They are literal hell, from a technical perspective. Traditional shell scripting languages from Bourne and Bourne Again shells are absolutely terrible. It’s like visiting an alien planet, where everything that makes sense in our world is upside down there. That is the biggest reason, why people resort to such tools like script, because classic Unix shells are just terrible at their job and we have to constantly fight with those shells to make something work. Newer and better shells are available, but unfortunately, you still have to write in Bourne or at least Bourne Again, because that is still the most widely used shell on earth, regarding Unix platforms. One new shell I like, is the following. https://www.nushell.sh/
  3. It complects things even further. Shells are terribly designed, as outlined above. Now, when you add more and more bloat on top of it, chances are things will work less & less. It just adds lots of complexity as a layer on top of the already complex & badly designed shell system.

Yes. Don’t use classic Unix shells. They are atrocious.

Things like this are one of the sub-reasons why shells are so terribly designed. There are so many different programs seemingly doing the same thing and yet it’s so different. It’s not obvious to a user, what the difference are and how it affects user experience. Terrible design.

Another reason is keeping everything infinitely backward compatible. This is another HUGE reason why shells are so atrocious. Yes, I do not care if a script written 25 years ago suddenly stops working. It does not have to work for 25 years. The maintainer has to eventually update it. Period. Such old scripts should break for the sake of improving the product’s, i.e. the shell in our case, quality of life.

Welcome to shell life. So much to do and nothing makes sense, except you read thousands of pages of manuals.


Programs like script exist, because traditional Unix shells are designed terribly. Shame on whoever was stuck in the 80s and thought we would still not exceed 4kb RAM in 2010.

If you want a better experience, use a different shell, simple as that. The reason this becomes so obvious in this scenario, is because script is basically a testimony to how traditional Unix shells are broken. You can only come up with the idea of creating such a program, if the program script should be used for is inherently broken and wrong.

I also would like to point out how extremely stupid the name script is for this program. You can never find anything useful on the internet, if you have an issue with it, because script already has too many meanings. Additionally, it’s not even related to what normal tech people understand as a “script”.
It should’ve been called unix-shell-logger or something like that.

I personally recommend Nushell. It’s great, but not yet 100% production ready.

1 Like

OK I shall try nushell. Probably too bleeding-edge for me

I also would like to point out how extremely stupid the 
name `script` is for this program. You can never find
 anything useful on the internet, if you have an issue
 with it, because `script` already has too many meanings.
 Additionally, it’s not even related to what normal tech
 people understand as a “script”.
It should’ve been called `unix-shell-logger` or something like that.

A script used to mean an exact copy of something… eg manuscript means a manually typed copy. Typescript means a copy made on a typewriter.
When computers came along they stole the word script and used it to mean a certain sort of program .
So I think the script command has the correct name, and I think shell programs should not be called scripts, they should be called shell-programs.

Also a script is not the same as a log. A log used to mean a set of entries made to record something, like driving hours on a truck. Not an exact copy of everything. So computers have distorted the meaning of the word log too.

And, I think most of the issues with script command are not shell issues. They are issues caused by using an exact copy of what was typed on the keyboard. What you get is almost like computer typesetting as done by roff, nroff, etc. Given that script comes from the same age as roff this is not surprising.

So I wish there was a way of making script usable, because we are stuck with sh, and there is no other way to record ones activities when making system changes.

Congratulations Rosika
You may have found the perfect substitute for script
It should record what you see on the screen, rather than what you type, so no backspaces
It starts a new shell, just to do the scripting.
Did you look at it with less or vi to see if there are control characters? Cat is not a full test.
Will give it a workout

And @Akito please note. It is a Bourne shell program. All those arcane shell features you complain about, are occasionally useful even if difficult to master.

Thank you Rosika
Regards
Nevillec

1 Like

I used to use script all the time on Solaris - Solaris came with it “out of the box”, just like “screen”… They weren’t things you had to add on later, unlike other things I could mention, Solaris did also come “out of the box” with tar, but it was AWFUL and most sysadmins grabbed GNU tar from Sunfreeware to replace it (that is until Oracle murdered Sunfreeware when they bought Sun microsystems purely to get the patents / trademarks / coypright for Java so Ellison could sue the pants of Sergei Brin and co @ Google).

Most of the “native” shells (except maybe KSH) that came with Solaris were atrocious… Hence why I’d often use script… But never really seen a need for it on Linux and I basically stopped using it when my job was barely any (or even none) Solaris…

I see. Did not know about. Thanks for explaining that to me. So, I can say: according to today’s meaning of “script”, the name has become misleading!

Indeed, you are correct. However, this is still the case. It’s just that sometimes you want to record everything, for debugging purposes, for example. So, it’s still true to the original meaning, I guess.

I was talking about the meta level. Why do we even need script? Why is it necessary? Because the shell does not give us enough transparency on what is happening, what happened and perhaps even what has changed. This is the problem and this is why I called it a shell problem.

It’s probably not a big improvement, if you are just going to use very basic commands. However, if you want to do anything advanced with the shell, then it will be a wonderful blessing compared to traditional Unix shells.

For example, the following is absolutely wonderful.

ls -d | to json

Beautiful. Absolutely beautiful.

I must admit, I am surprised at your response.
When I first encountered Bourne shell, it was like an academic challenge. Much more abstract than any of the mainframe interactive systems that preceded it.
It opened the door to a lot of things. It was the first environment I encountered where you could consider using output from one program as input for another. That was made possible by the Unix filesystem treating all files as a byte stream. It was a breakthru.
Things have got far more complex today. Other things like json are changing the way we put things together.
I am not against a new shell, but I would not like to see it go in the Msoft direction where they hide everything that the computer does from the user.
One of the appealing features of Unix and Linux is that they offer most users the chance to dive deeper into things. Some degree of academic appeal needs to be preserved without becoming so abstract that users are repelled.

So, if you do some system changes, eg apt-get upgrade, and then something goes wrong and you want to backtrack and see what happened, what do you do?
Just scroll back the window maybe? That has limitations.

1 Like

This is exactly what is terrible about it. It’s atrocious. Imagine writing a parser for every single Bash utility out there… You couldn’t do that in a lifetime and it wouldn’t make any sense. However, with Nushell for example, you can, as I provided an example for previously, just convert the structured data into JSON on the fly. No pain. No parser writing for you. Just use the shell. Don’t let it stand in your way.

Imagine you are working at the front desk and your supervisor tells you, you have to understand every single client walking in, no matter which language or dialect of a language he speaks. The Chinese language alone has roughly 50,000 dialects. Now, count in all the other languages on the planet.
Nobody would expect you to do that job, as requested.

However, when it comes to the Unix world and its shells, it suddenly seems like a perfectly legitimate way of handling intra-shell communication. Any character stream can mean anything. Wow. How amazing. The whole point of computers is, that they are extremely precise, to the point and don’t have feelings.
Now, if you make any character stream mean anything, you throw away everything a computer stands for and make it a mix out of the downsides of being a human and the downsides of a computer. You basically break the system.

JSON (or any modern plain text serialisation, really) makes everything simpler, understandable and workable. JSON is like the one universal “language”. It’s like a world, where everyone speaks English precisely the same way and everyone understands it the same way. It’s a dream for honest discussions and advancing humanity.

We techies don’t want that. A normal, average user just wants stuff to work. He doesn’t want to know how things work behind the scenes.

If you go to a movie theatre, do you request a behind the scenes documentary, before/after watching the movie?

That’s a misconception. Linux forces people to go deeper, for some of the simplest things. In Windows, you are never forced to dig deep. But you may do so, if you wish. I have experience in diving deeper into the Windows API for example and the biggest glaring thing that experience showed me, is that Windows is very deep and you can do a lot of things with it, but you are (almost) never forced to dive into it like that, so Linux seems like it’s more to the ground and accessible, when in fact it’s just an illusion driven by the fact, that Linux forces you to dive deep into different topics, because Linux just doesn’t work in those specific situations, whereas Windows generally works in regards to normal, average user desires.

Any apt-get implementation should use a JSON based log system and then you can automatically trace back any issue. The problem starts at the whole philosophy and attitude of outputting random characters to the screen, without even offering the option of having JSON output, not to mention automatic logging to a file in JSON format…

The whole system of having any character stream mean anything is one of the biggest issues with the whole Bourne + descendants design.

1 Like

I can swallow that. JSON makes sense.
But surely every program does not need to provide a logger. That is duplication. Just log the interactive session, that is what is needed.

This issue of logging all started when computing became interactive.
With batch systems, each batch run was its own log.

On the issue of Linux forcing people to go deeper, I dont know. I never felt forced, but I found it much easier to go deep in linux than in windows.

On character files. Most of my experience is with data. There are a limited number of formats there. In most cases it requires some external knowledge to interpret a data stream (Eg what the fields mean) . Databases tried to solve that, but they are not popular with data analysts. Most scientists just use ad hoc data formats and keep the format info outside the computer. I dont know if JSON will succeed there where databases have mostly failed.

1 Like

I made a file called tsh (transcript shell) containing
bash -i 2>&1 | tee transcript
then

nevj@trinity:~$ tsh
nevj@trinity:~$ cal
     July 2022        
Su Mo Tu We Th Fr Sa  
                1  2  
 3  4  5  6  7  8  9  
10 11 12 13 14 15 16  
17 18 19 20 21 22 23  
24 25 26 27 28 29 30  
31                    
nevj@trinity:~$ pwd
/home/nevj
nevj@trinity:~$ ls src
note.R
openblas.install.out
R-4.0.4
R-4.0.4.mkl
R-4.0.4.openblas
R-4.0.4.tar.gz
R-4.1.2
R-4.1.2.openblas
R-4.1.2.tar.gz
nevj@trinity:~$ exit
exit
nevj@trinity:~$ 

then

nevj@trinity:~$ cat transcript
nevj@trinity:~$ cal
     July 2022        
Su Mo Tu We Th Fr Sa  
                1  2  
 3  4  5  6  7  8  9  
10 11 12 13 14 15 16  
17 18 19 20 21 22 23  
24 25 26 27 28 29 30  
31                    
nevj@trinity:~$ pwd
/home/nevj
nevj@trinity:~$ ls src
note.R
openblas.install.out
R-4.0.4
R-4.0.4.mkl
R-4.0.4.openblas
R-4.0.4.tar.gz
R-4.1.2
R-4.1.2.openblas
R-4.1.2.tar.gz
nevj@trinity:~$ exit
exit

So, yes it works, but it does ls differently
Screenshot from 2022-07-17 16-50-53

That is, the transcript misses out on the tabbing and the color.

Other points

  • if I su within the transcript shell, it shows no prompt on the screen, and the transcript file shows no prompt and does not echo the commands.
  • su before doing tsh is OK … the prompt shows and it echoes commands. You hust have to remember to exit twice.
  • more transcript still misses some lines
  • less transcript does not miss lines, but shows ESC and ^M and those [?2004hESC]0 things associated with the command line prompt
  • less -R transcript is better , but still has ^M and 0; before each prompt.
  • script-declutter transcript | more works and more does not lose lines

The lines lost by more transcript are the first line after each command

after cal
^[[?2004l^M     July 2022
after pwd
^[[?2004l^M/home/nevj
after ls
^[[?2004l^Mnote.R
after exit
^[[?2004l^Mexit

They are the only lines that begin with ^[[?2004l^M
so that is what upsets more, but I do not understand why?

So how good is Rosika’s magic command?
About the same as script command… it keeps all the same control characters
and maybe a bit confusing if you use su
and it loses color and tabbing.

So, it is an interesting substitute for script and we may be able to fix the tabbing and color.

Cheers Rosika
Neville

Note on script-declutter… on an ls it removes color but not the tabbing. I think I can see how to stop it removing color. If I can fix script-declutter to leave color alone, I think the best solution so far is script-declutter typescript | more

1 Like