Who uses the 'script' command?

OK, acid test … try it all again on my rustc compiler output typescript made with script. Just use first few lines, first with script-declutter

That is the unaltered script-declutter which loses colour , but preserves everything else

Now I alter script-declutter and call it decl. Here is the modified perl script

nevj@trinity:~$ cat decl
#!/usr/bin/perl -wp

# clean up control characters and other non-text detritus that shows up
# when you run the "script" command.

BEGIN {
# xterm titlebar escape sequence
$xtermesc = "\x1b\x5d\x30\x3b";

# the occurence of a backspace event (e.g. cntrl H, cntrol W, or cntrl U)
$backspaceevent = "\x1b\\\x5b\x4b"; # note escaping of third character

# ANSI color escape sequence
#$ansiesc = qr/\x1b\[[\d;]*?m/;

# technically, this is arrow-right. For some reason, being used against
# very long backspace jobs. I don't fully understand this, as evidenced
# by the fact that is off by one sometimes.
$bizarrebs = qr/\x1b\[C/;

# used as part of the xterm titlebar mechanism, or when
# a bell sounds, which might happen when you backspace too much.
$bell = "\x07"; # could use \a

$cr = "\x0d"; # could use \r

$backspace = "\x08"; # could use \b
}

s/$xtermesc.+?$bell//g;
s/[$cr$bell]//g;
s/${backspaceevent}//g;
#s/$ansiesc//g;
while (s/(.)(?=$backspace)//) { s/$backspace//; } # frickin' sweet
# For every ^H delete the character immediately left of it, then delete the ^H.
# Perl's RE's aren't R, so I wonder if I could do this in one expression.
while (s/(..)(?=$bizarrebs)//) { s/$bizarrebs//; }

# notes
# ^[[7P has been spotted. Based on http://www.google.com/codesearch/p?hl=en#4qbG402gtc0/myScreen.C&q="[7P" it appears to be a numbered cursor jump, moving 7 characters (not sure if left or right).#!/usr/bin/perl -wp

You can see all I have done is comment out 2 lines which mention ansiesc which refers to ansi color escape codes
Now use that on my rustc output typescript

and we have color, without destroying anything else.

Now the interesting thing is using cat on this rustc typescript loses a line


The line starting Building [… is missing

And finally more on the same file


More makes an even bigger mess… it loses a different line… the one beginning with Compiling goldboot…
and it also muddles the last line.

That is enough for me.
I recommend ‘script-declutter’ if you are happy with black and white, or my modification called decl if you want to preserve color.

Thanks to @Rosika , @daniel.m.tripp and @Akito for contributing
Regards
Neville

1 Like

This goes back, to what I’ve been saying initially. The shell is lackluster, because you have to use the script hack to accomplish such task, instead of having it be possible by design.

I can’t imagine someone using Linux and never having to restort to the command line. At some point, depending on how extensively use the operating system, you will need to do it. It’s not a question of whether it happens, but when it happens. Sure, if a user just opens Firefox from time to time and otherwise literally only uses Kate, then it might be a long time until terminal interaction is needed. However, there will always be a time, when terminal interaction in Linux becomes unavoidable. Whether it’s a broken update or default settings changed for something that is not configurable via GUI, etc.
When using Windows however, you can use it for decades and not open a single terminal window once. The only times I had to open it is for actual Powershell scripting and other very advanced tasks. Never needed it for basic stuff, like changing an OS setting. In Linux there are tons of settings which require terminal access, because the GUIs are insufficient or not there, at all.

If you have a stream of arbitrary characters, each unique to every program one might use in a traditional Unix shell, you have that mess, because you always have to learn the “language” of the particular program. Now multiplay this with all available or used programs. It’s a huge mess.
Now, imagine, instead of having this mess, all programs speak the same “language”. They all speak JSON.
Suddenly, you can read ANY program’s output just like that. Without preparation. Without learning.
The only thing you need to get are the field names, etc. However, this is a trillion times less work & much simpler than actually learning a new “language”.
You could already write an R program, that automatically processes arbitrary JSON files.
If those JSON compatible programs would then additionally adhere to field naming conventions, it would be an utter breeze to process the outputs. It would be astonishingly simple & easy, compared to how it is the case now with traditional Unix shells.

I am not that familiar with the topic. Could you please elaborate on that and ideally provide real life examples? That would be an interesting read.

Its really just the attitude of scientists. Every experiment is a one-off, so they just enter some data, ram it thru some analysis software, then chuck it away. Only large long term collaborative projects
use databases or any sort of organised data structure.
Sounds sloppy… well it is.
Some journals try to get authors of papers to deposit data in repositories , but most of it is just lost.

1 Like

Hi Neville, :wave:

thanks a lot. :heart:

Actually I just tested it with cat.

But now I´ve done tests with cat, bat, less -R and vi.

Here are the results (from left to right):

Hmm, it seems you´re right.

bat seems to provide the same output as less -R.
All commands except for cat wouldn´t provide the cleaned-up result you were looking for.
Sorry. :slightly_frowning_face:

But what about the following solution:

script can also be used to create a pseudo video. To do this, the command must be called as follows:

script -t 2> timingfile video

This creates two files in the current directory, timingfile and video. timingfile contains the required time information, video the recorded log file. To replay, use the scriptreplay command:

scriptreplay timingfile video

translated from German (source: mentioned above / ubuntuusers)

(You can also pack the two files into one with the help of a script - if you´re interested.)

I used this method in the past and it worked perfectly.

Perhaps you´d like to give it a try, Neville? :blush:

Many greetings from Rosika :slightly_smiling_face:

What I was thinking of was the situation many years ago where every new program was providing an inbuilt editor just to manipulate its internal files. Fortunately sanity prevailed there , and programs started making their stuff available to a single external editor of the users choice.

Noone wants to have to learn 10 editors to use 10 programs.
Same applies to loggers or scripters.

1 Like

I saw that , but thought it was just about putting a timescale onto the scriptfile.
Will see what it does with my terrible rustc output script

By the way, did you see, cat can actually miss lines too.

Thank you,
Neville

1 Like

Hi Neville, :wave:

Well, it actually creates a pseudo-video, i.e. all the commands you enter and the output seen on the terminal are played back in the terminal with
scriptreplay timingfile video
It´s really great. :smiley:

Sorry, I guess I was was a bit un-attentive. I was just looking at my simple commands for my boldly-made statements.
Thanks for hinting towards that.

Many greetings.
Rosika :slightly_smiling_face:

1 Like