


Detailed explanation of scenario linux examples
Scenario linux--How to exit telnet gracefully in a script
Scenario
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:- The port is not open
$ telnet 101.199.97.65 62715
Trying 101.199.97.65... telnet: connect to address 101.199.97.65: Connection refusedAt this point, the command has exited.
- The port is open
$ telnet 101.199.97.65 62715
Trying 101.199.97.65... Connected to 101.199.97.65. Escape character is '^]'.The command has not exited at this time.
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>Run
quit at this time to truly exit.
telnet> quit
Connection closed.Among them, the Escape character can be customized, using the parameter
-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.Even so, exiting telnet is still troublesome. So, going one step further, how should I (gracefully) exit telnet if it appears in a script? PlanIn fact, it can be like this:
- Exit immediately after outputting the results
$ 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
- Delayed exit after outputting results
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.Using this method, the standard output and standard error can be redirected to a file, and the port open status can be determined by analyzing the contents of the file.
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!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

1. After logging in to your Meituan account, you first need to click on the [My] function. 2. After entering the [My] page, click the [Enter Wallet] function on the page. 3. The [Meituan Wallet] page will pop up, then scroll down to the bottom and click the [Meituan Mutual Aid] function in the [More Services] column. 4. At this time, you will enter the [Meituan Mutual Aid] page, and then click the [View Details] function on the page. 5. After entering the [Mutual Aid Details] page, scroll down to the bottom again, and then click the [Waiver of Protection] function. 6. A dialog box will pop up. Then click the [Deterministic Exit] function in the dialog box to successfully exit Meituan Mutual Aid.

Users can get various wallpapers by using wallpaperengine. Many users don't know why the wallpapers are gone after wallpaperengine exits. Dynamic wallpapers can only run on the desktop when the software you installed the wallpaper is turned on. Why are the wallpapers gone after wallpaperengine exits? 1. Dynamic wallpapers can only run on the desktop when the software you installed the wallpaper is turned on. 2. WallpaperEngine overwrites the original wallpaper, and of course it will be gone when you exit. 3. The wallpaper is still there after it is turned off, unless the file format is an image type, which can be obtained through some means, but it is not dynamic. 4. There is no video or dynamic image as a wall in Windows.

With the rapid development of mobile Internet, social media has become an indispensable part of people's lives. As one of the most popular social platforms, Douyin has won the love of a large number of users for its short video content and lively and interesting creativity. On Douyin, many users will join various fan groups, so what is the use of Douyin fan groups? 1. What is the use of Douyin fan club? The Douyin fan group provides users with a community that gathers interested enthusiasts. In this community, users can find like-minded people to discuss and share topics of interest. Whether you are a groupie, a music lover or a food expert, as long as you have the same interests and hobbies, you can find your own small circle in the Douyin fan group. The Douyin fan group also provides users with a

In previous win11 updates, we could skip logging in with a Microsoft account, but the latest win11 home version forces users to log in with a Microsoft account to install. However, logging in with a Microsoft account will cause a lot of trouble. Many friends want to log out after the installation is completed. Let me teach you how to exit. How to log out of Microsoft account in win11 1. First click on the start menu below and find "Settings" in it, as shown in the picture. 2. Find the "Users" or "accounts" option in the settings interface. 3. Find "Log in with a local account instead" in the user interface, which is a line of blue text. 4. Then just enter the password of our local account to log in to the local account and log out of the Microsoft account.

Can't exit win11 preview program? When we use the win11 system, the win11 preview program will be launched on the computer for us to use. However, some friends do not want to use this preview program. I hope this preview program can be launched. If you don’t know how to exit, the editor below We have compiled a tutorial guide for exiting the Win11 preview experience program. If you are interested, let’s take a look below! Tutorial guide for exiting the Win11 Insider Program 1. First press the shortcut key "win+i" to enter Windows Settings and click "Update and Security". 2. Then click "Windows Insider Program" in the left taskbar, as shown in the figure. 3. At this point you can see the experience on the right

1. Use the Apple Menu to Force Quit an Application on a Mac Using the Apple Menu to Force Quit an application on a Mac provides an easy way to deal with unresponsive or frozen applications without having to remember extra keyboard shortcuts. Here's how to force quit an app in macOS Sonoma: Click the Apple logo in the upper left corner of your Mac screen. Here, find and click on the “Force Quit” option in the drop-down menu that appears. Once completed, a pop-up window will appear with all the applications currently running on your Mac. Select the app you want to quit, then click the "Force Quit" button in the lower right corner of the window. 2. Use Keyboard Shortcuts to Force Quit Apps on Mac When you encounter the problem

Interoperability between major social platforms and applications has become the norm. As one of the most popular social software in China, WeChat’s authorization function is widely used in various APPs, including Douyin. However, as time goes by, some users may wish to cancel Douyin’s authorization to WeChat for privacy protection or other reasons. So many users may still not understand how to cancel WeChat’s authorization for Douyin. Below, the editor of this website will introduce you in detail the steps to cancel Douyin’s WeChat authorization. Users who want to know can come and follow Let’s continue this article to learn more! How to cancel WeChat authorization for Douyin. First, we open the WeChat app and then on the WeChat main page, click Settings and select the privacy function. Find Authorization Management in the privacy function and then find Douyin and select Delete.

How to exit win10 shortcut key mode? Although entering shortcut key mode can be used very well, it sometimes causes some troubles, so it needs to be turned off at this time. For this reason, we have brought a tutorial to see how to exit win10 shortcut key mode. Bar. Many friends don’t know how to operate in detail. The editor has compiled the steps to exit the win10 shortcut key mode below. If you are interested, follow the editor and take a look below! Steps to exit win10 shortcut mode 1. First press the shortcut key win+i to open Windows Settings, click Prepare 2. Then click Input on the left 3. Then click Advanced Keyboard Settings on the right 4. Click to select the input language hotkey 5. Click to change the key sequence 6. Select all unassigned&a
