As we all know, DOS has a non-commonly used command-redirection command, which is very useful. This command can also be used in Win9x/ME/2000/XP, the flexible use of this command can bring us great convenience-whether it is intrusion or defense or system application, it will bring great convenience. Today, let's take a look at several security application instances of redirection commands.
I. Command Format
Standard Input and Output of DOS are usually performed on the keyboard and display of the standard device. With redirection, you can easily change the input and output to a disk file or another device. Where:
1. Greater than ">" sends commands to files or devices, such as printers> prn. When ">" is used, some command outputs (such as error messages) cannot be redirected.
2. Add the command output to the end of the file without deleting the existing information in the file.
3. Get the input required by the command from the file instead of the keyboard.
4.> the & Symbol redirects the output from one default I/O Stream (stdout, stdin, stderr) to another default I/O Stream. For example, command> output_file 2> & 1 redirects all error messages in the command process from the screen to the standard file output. The standard output value is as follows:
Standard output equivalent value
Stdin 0
Stdout 1
Stderr 2
Both 1 and 2 create a file to store data; 4 may not be used in DOS.
Ii. Redirect command output
Almost all commands send output to the screen. Even the command that sends the output to the drive or printer displays messages and prompts on the screen. To redirect the output from the screen to a file or printer, use a greater than sign (> ). In most commands, a greater than sign can be used. For example, in the following command, the directory generated by the dircommand is redirected to the dirlist.txt file: dir> dirlist.txt. if the dirlist.txt file does not exist, the system creates the file. If dirlist.txt exists, the system replaces the information in the file with the output of the dir command.
To add the command output to the end of the file without losing any information in the file, use the double sign (> ). For example, in the following command, the directory generated by the dircommand is appended to the dirlist.txt file: dir> dirlist.txt, which redirects the input to a command, just like sending the command output to a file or printer instead of a screen, you can obtain command input from a file instead of a keyboard. To obtain the input from a file, use a smaller sign (<). For example, the following command retrieves the input of the sort command from the list.txt file: the sort system sorts the LIST. TXT files in alphabetical order and displays the results on the screen.