Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to operate screen recording on the command line of Linux

Shulou Source: shulou.com Published: 2022-06-01 15:49:05 09月22日 Update

This article focuses on "how to operate screen recording in the command line of Linux". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to operate screen recording on the command line of Linux.

Script and scriptreplay are available in most GNU/Linux distributions. Script is used to record the screen session to a file, and scriptreplay is used to play back the recorded screen session. Let's take a look at how it is implemented:

We can start by recording the screen session like this:

The code is as follows:

$script-T2 > timing.log-an output.session

$type commands; # now, as we usually do, enter whatever you want, as if nothing had happened.

.

.

Exit # may type N multiple commands, and if you think that's all you need to record, type exit to end it.

Description: the above two configuration files (timing.log, output.session) are passed to the script command as parameters, in which the timing.log file is used to store the time message of each command to run, and the output.session file is used to store the command output (in fact, the screen output). -t is used to dump to stderr the time data, so it is certainly customizable to redirect stderr to timing.log,timing.log and output.session with 2 >.

In the same path, we can use these two files to play back and forth the screen session:

The code is as follows:

$scriptreplay timing.log output.session

....

.... # here is what needs to be output.

Very simple, in addition, we only need to share these two files with others, and others can watch this "video". Of course, the deficiency is that there is no sound, but there is a considerable advantage that the files will be quite small and suitable for transmission on the Internet.

Next we will see how to achieve real-time broadcasting under the command line, this method is particularly suitable for teaching, and absolutely fluent.

First open two terminals,terminal1 and terminal2.

1. Enter the following command on terminal1:

The code is as follows:

$mkfifo scriptfifo # filename can be customized

2. Enter the following command on terminal2:

The code is as follows:

$cat scriptfifo # of course find the right path

3. Go back to terminal1 and enter the following command:

The code is as follows:

$script-f scriptfifo

$type commands

$.

$. # you may enter N multiple commands. When you do not need to broadcast, type exit and enter enter.

At this point, I believe you have a deeper understanding of "how to operate screen recording in the command line of Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Command input screen file code two content output actual method time path storage learning broadcast practical deeper fluent that is the Internet Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Apple OPPO Reno NVidia Shulou Tech Info