In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "which super-practical front-end improve shell commands", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "what super-practical front-end improve shell commands" bar!
Curl
Curl is a commonly used command-line tool for requesting Web servers. Its name means the URL tool for the client (client). Curl is very powerful, and its commands can be directly used by postman, and postman is also a request method that supports curl.
Commonly used result parameters
Curl parameters include many, here only a few commonly used, if you encounter a complex situation, you can refer to the documentation.
I don't know if there are other partners who don't know that postman directly supports curl commands. Clicking code in postman will show the curl command corresponding to the request.
The-X parameter specifies the method of the HTTP request.
The-H parameter adds the header of the HTTP request.
The-d parameter is used to send the data body of the POST request. After using the-d parameter, the HTTP request automatically adds the header Content-Type: application/x-www-form-urlencoded. And the request is automatically converted to the POST method, so-X POST can be omitted
The-b parameter is used to send Cookie to the server.
For more parameters, please take a look at teacher Ruan Yifeng's document https://www.ruanyifeng.com/blog/2019/09/curl-reference.html.
Application in curl project
If a partner who is familiar with curl can completely replace tools such as postman, the partner can simulate the request directly. (I think it's enough for curl to see and understand common commands.)
Because in BFF projects, the front end is also involved in the development, and we will directly call the back end interface. Sometimes we do not know if our parameters are written wrong, or if there is a problem with cookie, it is not convenient to find and debug the problem. In the local environment, we will directly print out the complete curl request. At this time, we can directly see the error. Developers only need to know some parameters of curl. You can also copy curl commands directly to postman for debugging. Take a look at the specific implementation part of the code.
/ / output if (ctx.app.config.env = 'local') {const str = curlString (url, {method, headers, body,}) +'\ n 'only in the local environment; console.log ('\ x1b [32m% s\ x1b [0m% s\ x1b [0m%, str);} / * Builds a curl command and returns the string. * @ param {String} url Endpoint * @ param {Object} options Object with headers, etc. (fetch format) * @ return {String} cURL command * / function curlString (url, options) {const method = options & & options.method & & typeof options.method = = 'string'? Options.method.toUpperCase (): 'GET'; const hasHeaders = options & & options.headers & & typeof options.headers = =' object'; const hasBody = options & & options.body; let curl = `\ ncurl-- request ${method}\ n--url'${url}'` If (hasHeaders) {curl + ='\ n' + Object.entries (options.headers) .filter (([key, value]) = > value! = = undefined) .map (([key, value]) = > `--header'${key}: ${value}') .join ('\\ n') } if (hasBody) {curl + = `\\ n--data'${bodyToDataString (options)}';} return curl;} / * Constructs a body string for use inside-- data * @ param {Object} options Object with headers, etc. (fetch format) * @ return {String} cURL command data string * / function bodyToDataString (options) {let parsedData Try {parsedData = JSON.parse (options.body);} catch (e) {/ / fall back to original body if it could not be parsed as JSON parsedData = options.body;} / / return an ampersand delimited string const headers = _ .get (options, 'headers'); const contentType = _ .toLower (_ .get (headers,' content-type') | | _ .get (headers, 'Content-Type')) If (contentType = = 'application/x-www-form-urlencoded') {if (typeof parsedData =' string') {return parsedData;} else {return Object.entries (parsedData) .map (([key, val]) = > `${key} = ${val}`) .join ('&');}} else {return JSON.stringify (parsedData);}}
Basic operation and configuration in vim
Non-insert mode
After vim opens the file, what are the basic operations you can do without using insert editing
Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community
G quickly move to the bottom of the file (often used to view logs)
Gg quickly moves to the top of the file
0 quickly move to the beginning of the line
$quickly move to the end of the line
: 13 quickly move to a specific line
Move the ZZ cursor to the middle of this screen
Dd cut the bank
Yy copy this line
U undo (undo abbreviation, undo)
P paste (p means paste, paste)
Under the mac system, you can click option+ to quickly move to the desired location (that is, the cursor)
Insert mode
After talking about a variety of mobile modes, let's end with a few commonly used insert commands, and I'll end with some commonly used simple ones here.
Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community
I edit in front of the current cursor
O quickly enter insert mode and navigate to the next line of editing
Esc exits insert mode, with
Ping
Ping is a very powerful TCP/IP tool in the network.
Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community
Used to detect the connectivity of the network and analyze the speed of the network
Get server IP according to domain name
Determine the operating system used by the other party and the number of packets passing through the router according to the TTL value returned by ping.
Bytes value: packet size, that is, bytes.
Time value: response time, the smaller the time, the faster you can connect to this address.
The TTL value: Time To Live, which indicates that DNS records how long it has been on the DNS server, is a value of the IP protocol packet that tells the router when the packet needs to be dropped. You can roughly determine whether the target system type is Windows series or UNIX/Linux series by the size of the TTL value returned by Ping.
By default, the Linux system has a TTL value of 64 or 255. The TTL value of the Windows NT _ TTL 2000 ~ XP system is 128, the TTL value of the Windows 98 system is 32, and the TTL value of the UNIX host is 255.
In addition to direct ping ip, you can also ping the domain name and automatically resolve the domain name to ip.
Application
The most commonly used method is to directly ping ip addresses to test network connectivity
Learn to read error messages
(1) NoAnswer: this fault indicates that the machine has a route to the central host, but has not received any information sent to the central host. The reasons may be: the central host is not working, the local or central host network configuration is incorrect, the local or central router is not working, the communication line is faulty, the central host has routing problems, and so on.
(2) Request Timed Out: timeout error, the tested machine can not connect properly, the reason may be that the host is not connected (such as shutdown), or the connection to the router is problematic, or the router cannot pass, or the other host uses firewall software to prohibit Ping testing, and so on.
(3) Unknown Host Name: the CVM name cannot be resolved. It may be that the DNS is set incorrectly, or the other CVM does not exist.
Telnet
Telnet can often determine the status of remote services, such as whether a port on a remote server is reachable (port connectivity).
Telenet is a windows standard service and can be used directly. If it is linux or mac, you need to install telnet yourself.
Use telnet ip port
1) use telnet to connect ports that do not exist
[root@localhost] # telnet 10.0.250.3 80 Trying 10.0.250.3...
Telnet: connect to address 10.0.250.3: Connection refused # Direct prompt connection denied
2) reconnect the existing port
[root@localhost] # telnet localhost 22 Trying:: 1. Connected to localhost. # see Connected and connect successfully to Escape character is'^]'. SSH-2.0-OpenSSH_5.3 a Protocol mismatch. Connection closed by foreign host. Thank you for your reading, the above is the content of "what super-practical front-end shell commands". After the study of this article, I believe you have a deeper understanding of what super-practical front-end shell commands are available, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.