remarks , Usage method : In the current directory, there should be a file with the address and port to be tested ip.txt, Example :
cat ip.txt
141.12.65.17 7500

#!/bin/bash
cur_dir=$(pwd)
ipfile=$cur_dir/ip.txt
logfile=$cur_dir/log.txt
date=`date`
echo "************${date}" >> $logfile
if [ ! -f "$ipfile" ]; then
echo " The system checks that there is no address list to test in the current path , Please add ip.txt Address list to test EXIT"
exit
fi
if [ ! -f "$logfile" ]; then
touch $cur_dir/log.txt
fi
cat $ipfile | while read line
do
result=`echo -e "\n" | telnet $line 2> /dev/null | grep Connected | wc -l`
if [ $result -eq 1 ]; then
echo " $line network is nomral" >> $logfile
else
echo " $line network is warried" >> $logfile
fi
done

shell Script implementation telnet More articles on testing service ports

  1. shell Script batch open firewall port

    # Be careful :shell Scripts execute commands in batches , You can't just write a function , And then copy all the commands in , I've tried this before, but it can't work . There must be a statement to judge whether the command is executed successfully # The simple command can not add the result judgment symbol , But when it comes to unpacking .sed ...

  2. solve shell Script telnet ap Automatically enter user name and password and carriage return

    #!/bin/bash function change_ap { ( s=`stty -g`; str=$"\n" sstr=$(echo -e $str) stty raw -e ...

  3. shell Scripts execute commands in batches ---- It is necessary to judge the result of the previous step -- There is no shortcut.

    # Be careful :shell Scripts execute commands in batches , You can't just write a function , And then copy all the commands in , I've tried this before, but it can't work . There must be a statement to judge whether the command is executed successfully # The simple command can not add the result judgment symbol , But when it comes to unpacking .sed ...

  4. telnet Log in to the router to start the service shell Script

    Because in the test, we often have to telnet Log in to the router to configure the environment and start the router , It's too much trouble to type in the command every time , I want to write a shell Script for automatic login . Configuration environment . The process of starting a service . The script implementation uses expect To achieve , therefore ...

  5. 【shell Script 】 Without stop telnet One ip Or domain name , And output the results to the file ===telnetscript.sh

    To write shell The script goes on and on telnet A domain name , And output the results to the file [root@localhost ~]# cat telnetscript.sh #!/bin/bash # Check if it is root Execute under the user ...

  6. Linux Deployment project shell The script to start And Centos7 Open designated port

    We're going to start with linux Installed on jdk   tomcat   mysql  These basic environments , These can be found in the building owner's   Linux introduction     Found inside . linux Deploy spring project 1. Right-click on the project ,maven ...

  7. How to use Shell Script to see if the ports of multiple servers are open ?

    When we configure the server , It is often necessary to check whether a port of the server is open . If there are only one or two servers , That's easy , Just use nc You can view the commands one by one . however , If your server is a cluster , There are a lot of them ? Well, if one by one ...

  8. Goddamn port occupancy ! Teach you how to use Shell The script kills it with one click !

    1. Preface Hello everyone , I'm Ango ! stay Web In development , Come across 「 Port occupied 」 Scene The general solution is : Use lsof -i Command to query the process occupying the port PID utilize kill -9 PID Kill the target process ...

  9. 【 turn 】 frequently-used shell Script

    from:http://blog.sina.com.cn/s/blog_4152a9f501013r6c.html frequently-used shell Script (2012-10-10 22:09:07) Reprint ▼ label : miscellaneous ...

Random recommendation

  1. c++ Realize it -- Simple processing of Chinese words

    Okay , How do we read it now , Then it is to study how to store and other details . First , The comparison function cannot be passed in char* Of the address of , But you can accept one string class . However , If it's two longer ones string class , ...

  2. matlab norm Use

    Format :n=norm(A,p) function :norm Functions can compute several different types of matrix norms , according to p Different norms can be obtained from different values Here are Matlab in help norm The explanation of NORM Matrix or vector n ...

  3. Makefile Android.mk It's a thought

    Before we write Android platform cocos2d-x In the game , In addition to writing  Classes  Outside the source code file inside , We also need to maintain its compiled files Android.mk, As we are Classes Add new ...

  4. Stanford Word Segmenter Use

    1, download Stanford Word Segmenter software package : Download Stanford Word Segmenter version 2014-06-16 2, stay eclipse Create a ...

  5. Python Several articles on concurrent programming

    Python Performance comparison of several concurrent implementation schemes  http://www.elias.cn/Python/PyConcurrency?from=Develop.PyConcurrency python Concurrent programming  h ...

  6. HISI VENC Actual output frame rate control

    https://blog.csdn.net/spy_007_/article/details/83688287 platform :HI3516EV100 SDK : Hi3516CV300_SDK_V1.0.2. ...

  7. [JAVA]JAVA Chapter 2 IOC And AOP What is it

    Use Spring Frame the process , It's just for the use of IOC( Dependency injection ), and AOP( Section oriented programming ), These two are Spring Soul . The main design patterns used are factory pattern and agent pattern . IOC It's a typical factory model , adopt ses ...

  8. linux How to change environment variables

    There are generally three ways : 1. Direct use export command : #export PATH=$PATH:/opt/au1200_rm/build_tools/bin Check whether it has been set up , Orders available export see : 2. repair ...

  9. concurrent HTTP request ,apache How to respond , And how to call php Of documents

    author : Dimple link :https://www.zhihu.com/question/23786410/answer/153455460 source : It's up to the author to own the copyright . Commercial reprint please contact the author for authorization , Non commercial reprint please indicate ...

  10. Orchard Module development full contact 7: Between order and payment Event Bus

    In this part , What we have to do is : 1: Turn the goods in the shopping cart into real orders : 2: understand Father son and one to many relationship : 3: Write a Event Bus The extension point : 4: Implement a simulation for the extension point Payment services : One : gen ...