Page 1 of 1

Some terminal magic -scriptreplay

Posted: 22 Sep 2015, 00:45
by viking60
Image
Image

When using Linux the terminal comes in handy but often I forget all that brilliant stuff that I did ..about five minutes after I am finished... :oops:
Inspiration and memory comes and goes...

So imagine you could "tape" everything you did in that terminal for the last hour - with the ability to play it back!

Wouldn't that be nice? No more terminal alzheimer and you can document eggzactly what you did.

Well in fact you are not replaying what you did as a movie, you are performing all those commands one more time. Every command from the last hour are now executing in your terminal.

..Like magic...

The script command lets you log everything you do to a log file.
You start the session like this

Code: Select all

script berserk.log

Then you can perform an inxi -Fz and a whoami and a w and a ls
this will all be logded until you type

Code: Select all

exit

If you are a tech and need to keep your back free regarding that work on the clients computer you can simply download that file to your dongle.

But that is just a boring log. +1 Moving on to the next computer you need to do eggzactly the same procedure you say?
Well this is where the magic comes in.

To make the log "replayable" we need to make that script command a little bit more complicated.

Code: Select all

script --timing=file.tm berserk.log

There is a need to add a timing file to make the replay work - there is no need to understand it; just call the file file.tm - like I have done above - and be done with it. +1
berserk.log is the name I have chosen to give my log file - you may choose something else.

Now you can start your session and type

Code: Select all

exit
when you are finished.

To repeat all commands from that session ...like magic:

Code: Select all

scriptreplay -t file.tm berserk.log

Hit enter.. and lean back and watch your terminal work :dance:

scriptreplay is mega cool :tux5:

More here

Check this out
Image

Re: Some terminal magic - showterm

Posted: 22 Sep 2015, 09:56
by viking60
As you can see above I have a recording of my terminal session that you can watch directly in your browser.
To achieve this a cheated a bit.

This is a recording, as in a movie, of my session. scriptreplay does actually repeat the session so how did I get this?

Well I installed showterm. In my case it was in the AUR (Arch User Repository).
In Centos 7 I only had to do a

Code: Select all

gem install showterm

ruby rubygems was already installed - if not do a

Code: Select all

sudo yum install ruby rubygems
first
:A
http://showterm.io/189f8f04dbc275a1148f0

Our Mageia using friends can do the same and if it fails you need to install rpm-build:

Code: Select all

sudo urpmi rpm-build

After that

Code: Select all

gem install showterm
will work just fine
:A
http://showterm.io/023817a17e9cfca927329


After that I simply type

Code: Select all

showterm
and the recording starts.
When I am finished I type

Code: Select all

exit
and the session gets uploaded to showterm.io and I get a link in my terminal - that I can paste in here for you to enjoy.
Image
You can control the speed of the replay by adding:

Code: Select all

#slow
#fast
#stop

to the link so to play the above at double speed it would look like this:
http://showterm.io/894f5cc846f5e6f58ab8d#fast (I am not sure that works all that well though) - the point is; you can add that to the link to speed up, stop, or slow down.

Here I am demonstrating the function of LC_ALL to make the output english.
:A
http://showterm.io/f9b1c91e5792dc944a83d
(Do we have a tip for that? :think: )
....
Yes we do: :A
viewtopic.php?f=25&t=3755&p=20635

Re: Some terminal magic -scriptreplay

Posted: 30 Sep 2015, 23:15
by dedanna1029
Very nice. My first project when I can finally get Linux installed.

Re: Some terminal magic -scriptreplay

Posted: 01 Oct 2015, 00:40
by viking60
Yup It should be possible for me to complete a session and send you the files file.tm and berserk.log. You could copy them to your computer and it will do the same work there as if I sat there and did it.
:C :-D

Re: Some terminal magic -scriptreplay

Posted: 01 Oct 2015, 08:38
by dedanna1029
:naughty: :lol:

Re: Some terminal magic -scriptreplay

Posted: 02 Oct 2015, 16:16
by viking60
I re-ran scriptreplay today with the stuff I do regularly and watched the terminal do my work....and got incredibly bored: Every coffee break :coffee_cup: and every visit to the toilet and all my scratching my head was there as looong pauses.

And it is a pain to watch how slow I am in real-time so some more magic is needed.

To speed up everything to be twice as fast:

Code: Select all

scriptreplay -t file.tm berserk.log -d 2

To speed up everything to be four times as fast:

Code: Select all

scriptreplay -t file.tm berserk.log -d 4

Now lets have a contest: What command do we need to speed up scriptreplay to be 6 times as fast :-D

...But even when the commands are flying over the terminal in a speed that makes me look super efficient there are those long pauses from fetching :coffee_cup: and going to the toilet.
Those pauses can be cut too +1
You simply specify the max length of the pause with the -m switch.
So to make your original entries four times as fast with maximum 2 second breaks here is the magic to make it happen:
:A

Code: Select all

scriptreplay -t file.tm berserk.log -d 4 -m 2


Naturally this does not speed up your computer so the update will take the usual time etc but the commands will be flying over your terminal and executed at impressive speed with maximum 2 sec between them.

:A
Image
http://showterm.io/e1f0fa94483bf1c97cf65

Re: Some terminal magic -scriptreplay

Posted: 02 Oct 2015, 20:41
by dedanna1029
Woooooooooooooooooooooowww.... *stunned