Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize linux shell script recording and playback Terminal session

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report