Save the execution result of the executable file

Source: Internet
Author: User
Article Title: Save the execution result of an executable file. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

When compiling test script files or applications on a Linux operating system, the results are usually output to the screen, instead, the system administrator wants to save the running results, error messages, and warning information in a file to facilitate analysis and adjustment. Although this can also be done through screen screenshots or screen recordings, it is inconvenient to process the result. For example, it is inconvenient to query and cannot be filtered. To solve this problem, a redirection tool is provided in Linux. During programming and debugging, you can use the redirection operation to store the output results of executable files.

1. Redirect input and output to different files respectively.

During program debugging, the information on the screen can be roughly divided into two parts: user input and program output. Sometimes the system administrator still wants to save user input while saving the output results of the script program. Only in this way can we compare the input and output to determine whether the input is invalid. To meet this requirement in advance, use the following command: Application name> output file <输入文件。在使用这个这个命令的时候,主要需要注意以下几点。< p>

First, pay attention to the redirection symbol. The direction of the redirection symbol is different, and its meaning is also different. For example,> symbol indicates output, which saves the output content of the script program to the file defined later. Symbol <则表示输入,即将用户的输入保存到其后面指定的文件中。如果这个符号写错的话,那么其输入输出的内容保存位置就会出现错误。不过这个语法没有问题,只是保存的地方相反了。< p>

Second, if these files do not exist in advance, the system will automatically create these files. If yes, the system overwrites the original file. Therefore, if the administrator needs to save the original results when testing the script program, they need to be saved in different files. Or use another symbol, instead of overwriting the original record, but simply appending. For example, you can use> symbol to replace>. Append an object using two> symbols in Linux. In this case, even if the original file exists, the system does not overwrite the record, but stores the output result under the original record. In this case, the system administrator can compare the output results to find out the cause of the problem.

However, you need to pay attention to a file whether to overwrite or replace it. When using the redirection symbol to record user output or input content, you must note that if the application outputs some graphical interfaces, the redirection symbol cannot save the information. At this time, only screen screenshots or screen recordings can be used to display the interfaces of these images. If no file path is specified, the system will create these files in the current directory by default and save the information. If the system administrator wants to save the information in the specified directory, add the path before the file name. In this command, you can determine the path or the relative path. For example, you can use $ HOME/file name to save the output or input results in your HOME directory.

2. Store normal output and error output in different files.

The script program output consists of two parts: normal output and error information. The content will be reflected on the screen. To better illustrate the problem, the system administrator may like to save the results in different files. In this case, it is very helpful for the system administrator to discover and track problems in the script. To achieve this, you need to use some parameters.

In Linux, the output is divided into two types: standard output stream and error output stream. The error output stream refers to the error message thrown by the system during script execution. The standard output stream refers to the execution result of the application. Because the system itself treats them as a small number of Operation streams, the standard output stream and the error output stream can be stored separately through commands. To achieve this, run the following command:> standard output file name 2> incorrect output file name.

 

[1] [2] Next page

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.