Prompt: view port usage and DOS MPs queue operations/Redirection operations

Source: Internet
Author: User

Since the Windows era, it is estimated that many people have forgotten this stuff. Today, I will review it a little bit.

 

First, let's look at the redirection/pipeline operation symbols in the doscommand.

 

">": Write the command output result to a file or device (such as a printer), rather than directly output the result to the screen.

Example:

C: \> DIR/W> dir_tree.txt

This command will list the directories and file names in the C: \ (C root directory) in a horizontal manner, and the final result will be generated in c: \ dir_tree.txt

Note: I usually use it to output the directory structure of the project.

C: \> tree D: \ workdir \ APP/F> app_dir_tree.txt

 

">": Similar to ">", the difference is that the original content of the file is not deleted (that is, the append text)

C: \> DIR/W> dir_tree.txt you can execute this command several times and compare it with the ">" operator.

 

Note:Use C #CodeYou can also specify redirectionFor example, the following code demonstrates how to call the ping command and obtain the returned result without the DOS running window

PROCESS p = new process (); p. startinfo. filename = "cmd.exe"; // close shell p. startinfo. useshellexecute = false; // enter "in" to redirect p. startinfo. redirectstandardinput = true; // enter "out" to redirect p. startinfo. redirectstandardoutput = true; // error output redirection p. startinfo. redirectstandarderror = true; // The window p. startinfo. createnowindow = true; p. start (); p. standardinput. writeline ("Ping www.cnblogs.com"); p. standardinput. writeline ("exit"); string P Ingreturn = P. standardoutput. readtoend (); string [] arr = pingreturn. split (environment. newline. tochararray (); int I = 0; foreach (string item in ARR) {If (item. indexof ("reply from ")! =-1) {I ++ ;}}if (I = 4) {response. Write ("Ping passed! ");} Else {response. Write (" No Ping! ");}

 

"|": Pipeline operation, usually used to connect two commands, that is, the output of a command is used as the input of the second command.

C: \> help | find "vol"

That is, the help output is used as the find input, and only the help information of the "vol" command is listed.

Check which processes are occupying port 80

 

The netstat command can be used to view port usage. There are many parameters in it, and several of them are very useful:

-A: List all connection and listening ports.
-O list process ID corresponding to each connection
-N: all addresses and port numbers are displayed in numbers.

Now you can use

C: \> netstat-a-O-N: view all the connections and ports of the local machine. The other three parameters can also be written together.

C: \> netstat-Aon

Combined with pipeline operation symbols, this solves the problem.

C: \> netstat-Aon | find ": 80"

In this way, we can find all the output results that contain: 80 connection information. If it is a local machine, you can also change ": 80" to something similar to "192.168.1.200: 80"

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.