The telnet command is the user interface of the TELNET protocol. It supports two modes: Command mode and Session Mode. Although telnet supports many commands, in most cases, we just use it to check whether the target host has opened a certain port (default is 23).
There are two execution results:$ telnet 101.199.97.65 62715
Trying 101.199.97.65... telnet: connect to address 101.199.97.65: Connection refused
$ telnet 101.199.97.65 62715
Trying 101.199.97.65... Connected to 101.199.97.65. Escape character is '^]'.
According to the prompt
Escape character is '^]'.It can be seen that the exit character is '^]' (CTRL+]). Entering other characters at this time will not cause it to exit, nor will CTRL+C. After entering CTRL+], it will be automatically executed and enter the command mode:
^]
telnet>
quit at this time to truly exit.
telnet> quit
Connection closed.
-e:
$ telnet -e p 101.199.97.65 62715 Telnet escape character is 'p'. Trying 101.199.97.65... Connected to 101.199.97.65. Escape character is 'p'. p telnet> quit Connection closed.
$ echo "" | telnet 101.199.97.65 62715
Trying 101.199.97.65... Connected to 101.199.97.65. Escape character is '^]'. Connection closed by foreign host.
$ echo "" | telnet 101.199.97.65 62715
Trying 101.199.97.65... telnet: connect to address 101.199.97.65: Connection refused
sleep 2 causes telnet to output results and stay for 2 seconds before exiting command mode.
$ sleep 2 | telnet 101.199.97.65 62715
Trying 101.199.97.65... Connected to 101.199.97.65. Escape character is '^]'. Connection closed by foreign host.
The above is the detailed content of Detailed explanation of scenario linux examples. For more information, please follow other related articles on the PHP Chinese website!