Check connectivity with multiple hosts - BASH script available here
Hi everyone!
Some time ago, I had to check connectivity with a big list of hosts, using different formats (protocol://server:port/path/, server:port, ....).
I developed a script that checks the connectivity using different commands (ping, telnet, nc, curl).
It worked for me so I'm sharing it now, hope you find it useful :)
Here's the code for connect.sh (v1.7 update: some fixes added, suggested by Scrutinizer):
Last edited by Fr3dY; 03-08-2015 at 05:07 PM..
Reason: v1.7: Misc. fixes added, as suggested by Scrutinizer
Thanks for the script. Here are a couple of observations:
Note: this permanently changes IFS throughout the script, not just local to the arrays assignment.
This does not do what you want, check what happens when status equals 2 vs. when it equals 3.
Why not just use a simple variable with a string?
This means that in order for the script to run, it has to be able to write in the current directory. The script does not check if it can write to the file...
f_processList does not loop throught the process, but calls itself recursively, which is not efficient, while using global variables which is not good practise..
Consider using case statements rather than if then elif then elif constructs...
This User Gave Thanks to Scrutinizer For This Post:
Thanks for the script. Here are a couple of observations:
Note: this permanently changes IFS throughout the script, not just local to the arrays assignment.
This does not do what you want, check what happens when status equals 2 vs. when it equals 3.
Why not just use a simple variable with a string?
This means that in order for the script to run, it has to be able to write in the current directory. The script does not check if it can write to the file...
f_processList does not loop throught the process, but calls itself recursively, which is not efficient, while using global variables which is not good practise..
Consider using case statements rather than if then elif then elif constructs...
Thanks for the advice! I'll implement your suggestions ASAP
ello,
i am new to the networking side.
I have a requirement to check the tcp network connectivity between server it's running on and the list of host's and ports combination.
please help me where i am going wrong.
my code:
#!/bin/bash
#read the file line by line
cd "$1"
cat... (17 Replies)
Hello,
I have a requirement to check the tcp network connectivity between server it's running on and the list of host's and ports combination.
i have written the below code but it doesn't work, but when i execute the nc command outside the script it works fine.
please help me where i am... (8 Replies)
I have a script to detect if a host is pingable or not. The problem is that I would like it to put the nonpingable hosts in one file and the pingable hosts in another. I have come up with this so far:
for ip in `cat /tmp/testlist2`; do ping -c 3 $ip >/dev/null && echo "$ip is up" || echo "$ip... (5 Replies)
I wonder whether someone can help me with what I'm trying to achieve
Basically, the objective is one script to create new user on more than 70 linux hosts if required.
Everything works apart from the highlighted part. It gave me an output
passwd: Unknown user name ''. when try to set... (35 Replies)
check the connectivity of the DBs through script, script should exit if no connection and display the output as below.
connectivity for DB1 is OK
connectivity for DB2 is OK
connectivity for DB3 is FAILED
for DB in 1 2 3
do
(sqlplus -s... (5 Replies)
Hi,
I need to check the sysbase database connectivity through the Unix Shell Script. Can you help me on the how to write the script to test the sysbase database connection.
Thanks in Advance
Nandha (0 Replies)
This past weekend I had some issues with my ISP.
So for future purpose I'm going to have some logging on my internet so I'm able to attach log files to my complaint email if this issue reoccurs.
Decided to do a simple ping script that runs every 5 or 10 min with crontab
if ping fail write date... (5 Replies)
So, first and foremost, I'm having issues with my internet connection. Periodically, the connection drops across the network. The fix is simple enough: restart the modem. However, this gets old when the connection dies out every hour.
I can hit my surfboard on 192.168.100.1, and navigate to a... (5 Replies)
I want to write a script to check if a unix box say abc.tdc.cin.net can be connected or not on certain port say 22. right know i have to telnet them manually from DOS prompt and if it is successful then isay it is connected.
Also to check Database connectivity I am using tnsping From DOS prompt.... (3 Replies)
I am trying get "df -k" output from multiple hosts along with their hostnames via ssh, my script is appending the "df -k" output from all the nodes to a single file but not getting the hostnames for those nodes, just wondering how to pass more than one command via ssh or may be someone could come... (6 Replies)