Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common network commands and symbols for batch processing in web development

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

In this issue, the editor will bring you about the network commands and symbols commonly used in batch processing in web development. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

one。 Test IP connection: ping

A command used to check whether the network is open or the speed of the network connection. Here, we only know some basic parameters.

-n count sends the number of Echo packets specified by count.

Defines the number of times packets are sent to the destination IP, which defaults to 4 times. Some information can be collected through this command. For example, what is the average return time of the packet?

What is the fastest time, what is the slowest time, and so on.

Example 1

C:\ Documents and Settings\ mzybar > ping-n 3 www.baidu.com

Pinging www.yisu.com [121.14.88.14] with 32 bytes of data:

Reply from 121.14.88.14: bytes=32 time=3ms TTL=57

Reply from 121.14.88.14: bytes=32 time=3ms TTL=57

Reply from 121.14.88.14: bytes=32 time=2ms TTL=57

Ping statistics for 121.14.88.14:

Packets: Sent = 3, Received = 3, Lost = 0 (0% loss)

Approximate round trip times in milli-seconds:

Minimum = 2ms, Maximum = 3ms, Average = 2ms

Let's analyze it:

Ping statistics for 121.14.88.14:

Packets: Sent = 3, Received = 3, Lost = 0 (0% loss)

From this we can see that in the process of sending three packets to www.baidu.com, three were returned, and there was no packet loss.

Approximate round trip times in milli-seconds:

Minimum = 2ms, Maximum = 3ms, Average = 2ms

Among the three packets, the fastest return speed is 2ms, the slowest is 3ms, and the average speed is 2ms.

Example 2

Ping-n 11 127.0.0.1 > nul

Ping native 11 times, can be used for batch processing delay of 10 seconds. The > nul in the command is masked output.

The short form can be written as follows:

Ping-n 11 127.1 > nul

-w timeout specifies the timeout interval in milliseconds.

Example 3

Ping 1-n 1-w 10000 2 > nul 1 > nul

The batch can be used for a delay of 10 seconds.

two。 View IP configuration: ipconfig

Since the TCP/IP configuration information of a computer is often intercepted in batch processing, we will just talk about the / all parameter here.

/ all parameter

Purpose: displays the complete TCP/IP configuration information for all adapters. When using IPConfig without any parameter options, it is for each already configured

The interface displays the IP address, subnet mask, and default gateway value.

Example 1

C:\ Documents and Settings\ mzybar > ipconfig

Windows IP Configuration

Ethernet adapter local connection:

Connection-specific DNS Suffix. :

IP Address. . . . . . . . . . . . : 192.168.0.73

Subnet Mask. . . . . . . . . . . : 255.255.255.0

Default Gateway. . . . . . . . . : 192.168.0.254

The information shown here is:

1. The local connection name of the computer is: local connection

two。 Native IP: 192.168.0.73

3. Subnet mask: 255.255.255.0

4. The default gateway is 192.168.0.254

Example 2

C:\ Documents and Settings\ mzybar > ipconfig / all

Windows IP Configuration

Host Name. . . . . . . . . . . . : Amur073 / / computer name

Primary Dns Suffix. . . . . . . :

Node Type. . . . . . . . . . . . : Unknown

IP Routing Enabled. . . . . . . . : No

WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter local connection: / / the local connection name of the computer

Connection-specific DNS Suffix. :

Description. . . . . . . . . . . Realtek RTL8168/8111 PCI-E Gigabit E / / Nic model

Thernet NIC

Physical Address. . . . . . . . . : 00-E0-4C-59-9B-57 / / MAC address of the network card

Dhcp Enabled. . . . . . . . . . . : No

IP Address. . . . . . . . . . . . : 192.168.0.73 / / IP address

Subnet Mask. . . . . . . . . . . : 255.255.255.0 / / Subnet mask

Default Gateway. . . . . . . . . : 192.168.0.254 / / default gateway address

DNS Servers. . . . . . . . . . . : 61.144.56.100 / / Primary DNS address

202.96.128.166 / / Deputy DNS address

When the ipconfig command takes the / all parameter, the full TCP/IP configuration information for all adapters will be displayed. If your computer has more than one network card, this life

Your parents will list their information one by one.

three。 Resolution address: arp

Displays and modifies items in the address Resolution Protocol (ARP) cache. The ARP cache contains one or more tables that store IP addresses and their passes through

The resolved Ethernet or token ring physical address. Each Ethernet or token Ring network adapter installed on your computer has its own separate table.

The-a parameter or the-g parameter is used to view all items in the cache. The results of-an and-g parameters are the same, and-g has been on the UNIX platform for many years.

The option to display all items in the ARP cache, while Windows uses arp-a (- a can be seen as all, that is, all), but it can also

Accept the more traditional-g option.

Arp-an IP

If we have multiple network cards, we can use arp-a plus the IP address of the corresponding network card to display only the ARP cache items associated with that network card.

By default IP, all current ARP cache tables are displayed.

Example 1

C:\ Documents and Settings\ mzybar > arp-a

Interface: 192.168.0.20-0x2

Internet Address Physical Address Type

192.168.0.00-1a-92-90-19-fe static

192.168.0.200-1a-92-90-19-eb static

192.168.0.3 00-1a-92-49-1c-a9 static

192.168.0.4 00-1a-92-90-19-32 static

192.168.0.5 00-1a-92-38-07-09 static

192.168.0.25200-23-54-a9-f5-4a dynamic

192.168.0.253 00-1d-60-1d-aa-d1 dynamic

192.168.0.254 00-0a-eb-0d-96-ff dynamic

Analyze the above data:

Internet Address: represents the IP address.

Physical Address: represents the physical address of the network card, that is, the MAC address of the network card.

Type: represents the type of ARP table, "dynamic" is dynamic, and "static" is static.

Arp-s IP physical address

We can manually enter a static item into the ARP cache. The project will remain valid during computer boot, or when an error occurs

In case of error, the manually configured physical address will automatically update the project. ARP binding can be achieved through this command.

Example 2

Arp-s 192.168.1.1 00-1a-92-90-19-fe

Add static ARP to 192.168.1.1 to implement ARP binding.

Arp-d IP

Use this command to manually delete a static project. You can enter the arp-d command, and the arp table of the current computer will be deleted by default IP.

In dealing with ARP spoofing, we usually delete the arp table of the current computer before implementing ARP binding.

Example 3

Echo offarp-darp-s 192.168.0.1 00-1a-92-90-19-fearp-s 192.168.0.2 00-1a-92-90-19-ebarp-s 192.168.0.3 00-1a-92-49-1c-a9arp-s 192.168.0.4 00-1a-92-90-19-32arp-s 192.168.0.5 00-1a-92-38-07-09pause

four。 Open command: start

Basic format: start "title" filename

Title can be omitted, and filename with spaces or special symbols is enclosed with "".

Example 1

Start http://www.baidu.com

Here is to open Baidu, title omitted.

Example 2

Start ""% windir%\ system32\ NOTEPAD.EXE ""% userprofile%\ Desktop\ abc.txt "

Use NOTEPAD (notepad) to open abc.txt on your desktop.

Example 3

Start ""% userprofile%\ Desktop\ abc.doc "

Here you need to add "" after start to start the file abc.doc, otherwise you can't start it.

If there is no "" after start, the title is omitted. If there is a "" in the file name, the start will regard it as a title and become omitted.

File name, cmd is enabled by default. So adding "" after start can prevent this kind of unexpected situation.

The parameters / min and / max minimize and maximize the open window.

Example 4

Start / min ""% windir%\ system32\ NOTEPAD.EXE ""% userprofile%\ Desktop\ abc.txt "

Use notepad to minimize the abc.txt that opens the desktop.

five。 Shut down or restart the computer: shutdown

Usage: shutdown [- I |-l |-s |-r |-a] [- f] [- m\\ computername] [- t xx] [- c "comment"] [- d up:xx:yy]

There are no parameters to display this message (with? Same)

-I display the GUI interface, must be the first option

-l logout (cannot be used with option-m)

-s shut down this computer

-r shut down and restart this computer

-an abandon system shutdown

-m\\ computername remote computer shutdown / restart / abandon

-t xx sets the timeout to be turned off to xx seconds

-c "comment" turns off comments (127characters maximum)

-f forces the running application to close without warning

-d [u] [p]: xx:yy shutdown reason code

U is the user code

P is a planned shutdown code

Xx is a primary reason code (a positive integer less than 256)

Yy is a secondary reason code (a positive integer less than 65536)

Example 1

Shutdown-l

This command can only log out of local users and does not apply to remote computers.

Example 2

At 12:00 shutdown-s

Perform a shutdown of the computer at 12:00 with the-s argument.

Example 3

Shutdown-r-t 60

Restart the computer in 60 seconds. Here is to set the restart countdown to 60 seconds. If the time is not set, the default is 30 seconds.

Example 4

Shutdown-f-s-t 300

Force the computer to shut down after 300 seconds with the-f parameter.

Example 5

Shutdown-a

When we encounter a shock wave or shock wave virus, or execute the above shutdown command, we can use shutdown-a to terminate the current shutdown.

Cheng, in this way, the loss caused by the shutdown can be avoided.

six。 Closes the specified process taskkill

The Taskkill command can end one or more tasks or processes based on the process ID or image name.

/ im ImageName

Specifies the image name of the process that will be terminated.

Example 1

Taskkill / im qq.exe

/ f process

Specifies the process that will be forcibly terminated. This parameter can be ignored for remote processes, and all remote processes will be forcibly terminated.

Example 2

Taskkill / f / im spoolsv.exe

/ pid process id specifies the PID of the process to be terminated

Example 3

Taskkill / pid 1230 / pid 1241 / pid 1253

Here is the process of terminating the PID of 1230 1241 1253 respectively.

There are still a lot of network commands about DOS, some of which are very powerful, such as regsvr32,netsh,sc,wmic, etc., so I won't say much about it. I hope

Let's do more to search for relevant information, ^ & ^

2.2 Learning special symbols in common use

Key points of study:

1. > redirector

2. | Command pipe character

3. &, & &, | | combine commands

4.^ escape characters

5.% variable leader

6. "" delimiter

1. Redirects >, > >

The redirector, which means to pass and overwrite, is used to pass the result of the run to the following scope (either a file or a default)

Recognized system console, that is, the command prompt).

Example 1

Echo hello120 > 1.txt

The newly created file 1.txt with the content "hello120" (Note: there is a space at the end of the line and a blank line after the file)

Example 2

(echo hello120) > 1.txt newly created file 1.txt with the content "hello120" (Note: there is no space at the end of the line, but there is a blank line after the file)

> 1.txt echo hello120 newly created file 1.txt with the content of "hello120" (Note: there is no space at the end of the line, but there is a blank line after the file)

Example 3

> after the 1.txt 1.txt set / p=hello120 redirector command, it will be overwritten by the new content, this must be noted!

The redirector appends the output of the command to the device that follows it. The function of this symbol is similar to >, but there is a difference between them.

Pass and append to the end of the file, and > is overwritten. The usage is the same as >.

Example 1

Echo hello120 > > 1.txt

If 1.txt does not exist, create a new file 1.txt with the content "hello120"; if 1.txt exists, append the content as "hello120"

To the end of the article.

Example 2

Echo hello > 1.txt

Echo world > > 1.txt

At this point, the 1.txt content is as follows:

Hello

World

2. Command pipe character |

It means to take the execution result of the command or statement before it as the processing object of the command or statement after it. In short, it takes the output before it as

For the input after it.

Example 1

Tasklist | find / I "qq.exe" & & taskkill / f / im qq.exe

Pass the tasklist (process list) to the find command with the pass character "|" to execute the process of finding the QQ.

Example 2

Echo Y | rd / s c:\ abc

Pass the result of echo y to the rd / s c:\ abc command through the pipe command | to enter y automatically.

★ Note: input method of pipe command |, shift key\

3. Combine commands &, & &, | |

&, & &, | | is a combined command, which, as the name implies, can be executed by combining multiple commands into a single command.

The & symbol allows multiple commands to be executed at the same time, and when the first command fails, it does not affect the execution of subsequent commands. Here & the commands on both sides are executed sequentially

To be executed from the back of the trip.

Format: first command & second command [& third command.]

Example 1

Dir z:\ & dir y:\ & dir c:\

The above command will continuously display the contents of disk c, regardless of whether the disk exists.

The & & symbol allows multiple commands to be executed at the same time. Subsequent commands will not be executed when an error is encountered, and will be executed all the time if there has been no error.

All orders.

Format: first command & & second command [& & third command.]

Example 2

Dir z:\ & & dir y:\ & & dir c:\

This command is similar to the one above, except that when the previous command fails, the latter command will not be executed again.

| symbol allows multiple commands to be executed at the same time. When one command fails, the second command is executed. When the correct command is executed, it will not be executed later. | |

If the correct command does not appear, all commands are executed all the time.

Format: first command | | second command [| | third command.]

Example 3

Tasklist | find / I "qq.exe" & & taskkill / f / im qq.exe | | echo, have you opened QQ? I don't believe it

The & & and | | two symbols can be considered to divide the above example into three commands:

The first command:: tasklist | find / I "qq.exe"

Second command: taskkill / f / im qq.exe

The third order: echo, did you open QQ? I don't believe it

Let's analyze it here.

If the QQ process cannot be found, that is, the first command execution fails, then & & will not execute the second command: the taskkill command, because the taskkill command does not

If the second command is considered to have failed, then | | the third command will be executed: the echo command.

If the QQ process is found, that is, the first command is executed successfully, then & & will execute the second command: the taskkill command, because the second command is executed successfully

| | the third command, echo, will not be executed.

Input method of ★ pipe command | |. Enter the shift key twice.

The ★ combination command must pay attention to the priority when used with the redirect command and the pipe command. The priority of pipeline command is higher than that of redirection command, and the priority of redirection command is superior to that of redirection command.

The level is higher than the combined command.

Think about:

List the files and folders of drives C and D into the a.txt file.

You may have written the following command right away:

Dir c:\ & & dir d:\ > a.txt

After this execution, there is only D disk information in the a.txt! Why? Because the priority of the combined command is not as high as that of the redirect command! So orders are being carried out.

The line time will be divided into two parts: dir c:\ and dir d:\ > a.txt

Here we want to use the combined command & & to meet the requirements of the title, we can write:

Dir c:\ > a.txt & & dir d:\ > a.txt

In this way, according to the priority, DOS will divide the sentence into the following two parts: dir c:\ > a.txt and dir d: > a.txt

Of course, we can also write:

Dir c:\ > a.txt & dir d:\ > a.txt

Escape character ^

In general, ^ appears as an escaped character.

Because in the cmd environment, some characters have special functions, such as >, > > for redirection, | for pipe, &, & &, | | for statement connection. it

They all have specific functions. If you need to output them as characters, echo >, echo |. Things like this will go wrong-- the cmd interpreter will

When they are treated as characters with special functions rather than as ordinary characters, these special characters need to be escaped: in

Each special character is preceded by the escape character ^.

Therefore, to output these special characters, you need to use echo ^ >, echo ^ |, echo ^ | ^ |, echo ^ ^. And other formats to deal with

In addition, this escape character can also be used as a continuation symbol.

Example 1

@ echo off

Echo, this is ^.

A ^

Sentence

Pause

Why does an escape character act as a continuation character at the end of a line? The reason is simple, because there is an invisible symbol at the end of each line, that is, enter

Character, the escape character invalidates the carriage return when it is at the end of the line, thus continuing the line.

5. Variable leader%

① generally handles variable references when the percent sign appears in pairs and contains non-special characters, such as% var%,% str%

Example 1

The value of the @ echo offset str=abcecho variable str is:% str%pause

The result is displayed on the screen:

The value of the variable str is: abc

Press any key to continue.

② in addition, the percent sign as a variable reference has a special form, that is, the reference to the formal parameter, at this time, a single percent sign is followed by 09.10

Number, such as 0, 1, 2.

0 represents the batch file itself, including the full path and extension

1 to 9 represent the first parameter to the ninth parameter

Example 2

@ echo offif defined str goto nextset str=set / p str= Please drag the file to this window and enter: call "% ~ 0"% str%pause:nextclsecho the full path of this batch file is: "% ~ 0" echo the full path of the file dragged to this window is: "% ~ 1" goto: eof

When ③ appears in a set / a statement, it represents the division of two numbers by the remainder, which is the so-called modular operation, how it is written in command line windows and batch files.

Slightly different: in the command line window, only a single% is required, and in a batch file, two consecutive percent signs are required, written as%%.

For example, if you run set / a num=4%2 in the command line window, the result will display 0 because the remainder of 4 divided by 2 is 0

If you save as a batch file, this statement will change slightly:

Example 3

@ echo offset / a num=4%%2echo 4 divided by 2 the remainder is% num%pause

④ escape symbol: if you want to display% itself, you need to escape with% in front of it.

Example 4

@ echo offecho one percent sign:%% echo two percent signs:% echo three percent signs:% pause

VI. Delimiter ""

① often uses "" to enclose a path when it represents a path with spaces or special symbols.

Example 1

Cd / d cd "d:\ program files\ ^% * abc"

Because there are spaces and special symbols in the path, use "" to enclose the path.

② indicates that the content is a complete string.

Example 2

@ echo off

Set "var=abc 123"

Echo var%

Pause

This means that the value of the variable var is the string "abc 123".

These are the common network commands and symbols for batch processing in web development shared by Xiaobian. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report