Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize linux shell script recording and playback Terminal session

Shulou Source: shulou.com Published: 2022-06-03 07:42:41 10月01日 Update

This article mainly explains "how to achieve linux shell script recording and playback terminal session", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to achieve linux shell script recording and playback terminal session" bar!

The code is as follows:

Amosli@amosli-pc:~/learn$ script-T2 > timing.log-an output.session# starts recording

Script started, file is output.session

Amosli@amosli-pc:~/learn$ hello1

No command 'hello1' found, did you mean:

Command 'hello' from package' hello-debhelper' (main)

Command 'hello' from package' hello' (main)

Hello1: command not found

Amosli@amosli-pc:~/learn$ who

Amosli tty7 2013-12-19 22:58

Amosli pts/1 2013-12-19 22:59

Amosli pts/2 2013-12-19 23:16

Amosli@amosli-pc:~/learn$ time

Real 0m0.000s

User 0m0.000s

Sys 0m0.000s

Amosli@amosli-pc:~/learn$ date

Friday, 20 December 2013, 01:06:41 CST

Amosli@amosli-pc:~/learn$ exit

Exit # end recording

Script done, file is output.session

Play the recording:

The code is as follows:

Amosli@amosli-pc:~/learn$ scriptreplay timing.log output.session # output by playback command sequence

Amosli@amosli-pc:~/learn$ hello1

No command 'hello1' found, did you mean:

Command 'hello' from package' hello-debhelper' (main)

Command 'hello' from package' hello' (main)

Hello1: command not found

Amosli@amosli-pc:~/learn$ who

Amosli tty7 2013-12-19 22:58

Amosli pts/1 2013-12-19 22:59

Amosli pts/2 2013-12-19 23:16

Amosli@amosli-pc:~/learn$ time

Real 0m0.000s

User 0m0.000s

Sys 0m0.000s

Amosli@amosli-pc:~/learn$ date

Friday, 20 December 2013, 01:06:41 CST

Amosli@amosli-pc:~/learn$ exit

Amosli@amosli-pc:~/learn$

Conduct a broadcast video session between multiple users: open two terminals

(1) enter the following command in Terminal 1:

The code is as follows:

Mkfifo scriptfifo

(2) enter the following command in Terminal 2:

The code is as follows:

Cat scriptfifo

(3) return to Terminal 1 and enter the following command:

The code is as follows:

Script-f scriptfifo

Commands...

In this way, the role of broadcasting and online classes is realized, which is very magical!

The output of my own experiment:

The code is as follows:

Terminal 1:

Amosli@amosli-pc:~$ mkfifo scriptfifo

Amosli@amosli-pc:~$ script-f scriptfifo

Script started, file is scriptfifo

Amosli@amosli-pc:~$ who

Amosli tty7 2013-12-19 22:58

Amosli pts/1 2013-12-19 22:59

Amosli pts/2 2013-12-20 01:14

Amosli pts/4 2013-12-20 01:16

Amosli pts/5 2013-12-20 01:20

Amosli pts/6 2013-12-20 01:20

Amosli@amosli-pc:~$

Terminal 2:

Amosli@amosli-pc:~$ cat scriptfifo

Script started on 20 December 2013 Friday, 01:21:19

Amosli@amosli-pc:~$ who

Amosli tty7 2013-12-19 22:58

Amosli pts/1 2013-12-19 22:59

Amosli pts/2 2013-12-20 01:14

Amosli pts/4 2013-12-20 01:16

Amosli pts/5 2013-12-20 01:20

Amosli pts/6 2013-12-20 01:20

Amosli@amosli-pc:~$

Thank you for reading, the above is the content of "how to achieve linux shell script recording and playback terminal session". After the study of this article, I believe you have a deeper understanding of how to achieve linux shell script recording and playback terminal conversation, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Terminal code script command week learning input content broadcast output magic two between function online classroom multiple that is sequence idea situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux MariaDB MySQL Docker