Linux Notes terminal logging tool script

Source: Internet
Author: User
Tags control characters

When learning Linux, sometimes the terminal printing message is very important to us, but the terminal display also has a certain buffer space, when the printing information is very long, the front of the information will be overwritten, so here online search for a bit of this introduction, now summarized as follows:

Script is a very useful tool, and it's fun enough. Script can record the session process of the terminal, and then use Scriptreplay to play the results of their recordings to others to watch. The benefit of script is that all of your operations in the terminal can be recorded in its own way. We can apply this recording in many ways, such as teaching, presentation, and so on.


In general, script and Scriptreplay have a default installation in the Linux distribution. If you plan to start recording a terminal session using script, you can do this by typing the following command:
Script-t 2>yangrui.timing-a yangrui.session
The-t option in this directive indicates the time data for the output recording, and the-a option outputs the recorded file (if the file already exists, the data is added later). You can change the Yangrui in the directive to the name of the file you set. When you return the message "Script started, file is Yangrui.session" in the terminal, you can do what you need to record.

If you need to end the recording process, enter

To play a terminal session that has been recorded, you can use the command:

   Scriptreplay yangrui.timing yangrui.session
You can look at the action like a movie, but not fast forward (or maybe I haven't found it, and if any one knows, you can teach me by the way). Personal advice to use:
Cat Yangrui.session

View the content. If you open yangrui.session in the graphical interface, you'll find that the file will be filled with control characters and ANSI escape sequences that look like garbled:


The workaround can be found on the Internet, and personal advice is available on the command line.


Next time you want to continue recording, enter it again:

Script-t 2>yangrui.timing-a yangrui.session

It will put the recorded data behind the last data, and automatically separated by time.


For more information about script and Scriptreplay, you can use the man script or the man Scriptreplay query.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.