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

What is the use of the scriptreplay command in Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail what is the use of the scriptreplay command in Linux. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Linux commonly used command scriptreplay is used in the terminal to reproduce the output information of all operations and commands of the user at that time according to the terminal data file and time log file recorded by the script command.

Scriptreplay replays all actions of the terminal session

In short, replay all the information that happened in the terminal session instead of rerunning the command. For example, when a user enters a command, the typing and deletion of characters will also be reproduced. It is very suitable for tutorial demonstration situations. Moreover, the terminal operation is recorded by using the script command on machine A, and the scriptreplay command can be replayed on machine B.

Syntax scriptreplay [options] [- t] timingfile [typescript [divisor]] option-t,-- timingfile # record time log file name-s,-- typescript file # log file name-d,-- divisor number # means double speed playback Dividing the time interval recorded by the time log file by number #-d 2 indicates that the playback speed is twice the speed of the original input single command. -d 0.1 indicates that the speed of playing a single command slows down 10 times.-- maxdelay number # indicates the maximum delay time between commands (in seconds) #-m 2 indicates that the interval between two commands stored in command.log is greater than two seconds. Press two seconds to play-V,-- version # displays version information and exits-h,-- help # displays help text and exits parameter time log file: the name of the file in which the time log information is stored

Terminal data file: the name of the file that stores terminal data information

For example # to replay the terminal content, the default first parameter is the time log, and the second parameter is the terminal data file scriptreplay time.file command.log # replay the terminal content with a fast forward speed of 1, and the maximum delay between commands is 2 seconds scriptreplay-d 1-m 2-t time.file-s command.log to record the terminal content to the file.

Zfb@localhost:~$ script-T2 > time.file-a-f command.log Script started, file is command.log zfb@localhost:~$ echo "hello, world" hello, world zfb@localhost:~$ echo $(date "+% Y-%m-%d% H:%M:%S") 2020-12-23 20:48:46 zfb@localhost:~$ echo "Bye" Bye zfb@localhost:~$ ls-al total 20 drwxr-xr-x 2 zfb zfb 4096 Dec 23 20:48. Drwxr-xr-x 37 zfb zfb 4096 Dec 23 20:49.. -rw-r--r-- 1 zfb zfb 0 Dec 23 19:03 a.txt-rw-r--r-- 1 zfb zfb 12 Dec 23 19:04 b.txt-rw-r--r-- 1 zfb zfb 2744 Dec 23 20:49 command.log-rw-r--r-- 1 zfb zfb 790 Dec 23 20:49 time.file zfb@localhost:~$ exit Script done, file is command.log zfb@localhost:~$ replay terminal content

Zfb@localhost:~$ scriptreplay-d 1-m 2-t time.file-s command.log zfb@localhost:~$ echo "hello, world" hello, world zfb@localhost:~$ echo $(date "+% Y-%m-%d% H:%M:%S") 2020-12-23 20:48:46 zfb@localhost:~$ echo "Bye" Bye zfb@localhost:~$ ls-al total 20 drwxr-xr-x 2 zfb zfb 4096 Dec 23 20:48. Drwxr-xr-x 37 zfb zfb 4096 Dec 23 20:49.. -rw-r--r-- 1 zfb zfb 0 Dec 23 19:03 a.txt-rw-r--r-- 1 zfb zfb 12 Dec 23 19:04 b.txt-rw-r--r-- 1 zfb zfb 2744 Dec 23 20:49 command.log-rw-r--r-- 1 zfb zfb 790 Dec 23 20:49 time.file zfb@localhost:~$ exit zfb@localhost:~$ of which only the command scriptreplay-d 1-m 2-t time.file-s command.log is user input The rest are automatically rendered (and the visual effects are consistent with the actions of real users). By looking at the time output above at 20:48:46, it can be proved that this is a replay of the record at that time, rather than a re-execution of the command. In other words, time.file and command.log files can be moved to any machine that supports scriptreplay commands, and command input and terminal echo can be dynamically reproduced.

This is the end of this article on "what is the use of scriptreplay commands in Linux?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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