Method of operating screen recording in command line of Linux

Time:2021-10-12

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 see how to implement it:

We can start by recording the screen session:

Copy code

The code is as follows:

$ script -t 2> timing.log -a output.session</p>

Note: the above two configuration files (timing.log and output.session) are passed to the script command as parameters. The timing.log file is used to store the running time information of each command, and the output.session file is used to store the command output (actually screen output) . – t is used to dump time data to stderr, so we redirect stderr to timing.log with 2 >. Timing.log and output.session can be customized.

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

Copy code

The code is as follows:

$ scriptreplay timing.log output.session</p>

It’s very simple. In addition, we only need to share these two files with others, and others can watch this “video”. Of course, the disadvantage is that there is no sound, but there is a great advantage. The file will be quite small and suitable for transmission on the Internet.

 

Next, let’s see how to realize real-time broadcasting under the command line. This method is especially suitable for teaching and is absolutely fluent.

First open two terminals, Terminal1 and Terminal2.

1. Enter the following command on Terminal1:

  

Copy code

The code is as follows:

$mkfifo scriptfifo # file name can be customized

2. Enter the following command on Terminal2:

  

Copy code

The code is as follows:

$cat scriptfifo # of course, find the right path

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

  

Copy code

The code is as follows:

$ script -f scriptfifo</p>

In this way, if your student opens terminal 2, he / she can see how you (teacher) operate in real time.

Recommended Today

The selector returned by ngrx store createselector performs one-step debugging of fetching logic

Test source code: import { Component } from ‘@angular/core’; import { createSelector } from ‘@ngrx/store’; export interface State { counter1: number; counter2: number; } export const selectCounter1 = (state: State) => state.counter1; export const selectCounter2 = (state: State) => state.counter2; export const selectTotal = createSelector( selectCounter1, selectCounter2, (counter1, counter2) => counter1 + counter2 ); // […]