Help with to check the tcp network connectivity between servers and hosts


 
Thread Tools Search this Thread
Special Forums IP Networking Help with to check the tcp network connectivity between servers and hosts
# 8  
Old 06-01-2014
What is this construct:'(nc -zv $hosts)'? If you want to use command substitution, use $(...). That will make the exit code available via $? as well. You may need to redirect stderr to stdout to capture the error msg.
# 9  
Old 06-02-2014
Hello,

My below code still not working, if the connection is rejected , the output is not appending to the output file.

code:
Code:
#!/bin/bash
#read the file line by line

cd "$1"
cat testping.txt | while read line
do
        # check if there are no blank lines
        if [ ! -z $line ]; then
                hosts=${line//:/ }
                nc -z $hosts >> testoutput.txt 2>&1
        fi
done


if there is any hosts with connection rejected, the entry is not available in the oyutput file.

please help.
# 10  
Old 06-02-2014
Quote:
Originally Posted by sknovice
Hello,

My below code still not working, if the connection is rejected , the output is not appending to the output file.

code:
Code:
#!/bin/bash
#read the file line by line

cd "$1"
cat testping.txt | while read line
do
        # check if there are no blank lines
        if [ ! -z $line ]; then
                hosts=${line//:/ }
                nc -z $hosts >> testoutput.txt 2>&1
        fi
done


if there is any hosts with connection rejected, the entry is not available in the oyutput file.

please help.
Try changing:
Code:
        if [ ! -z $line ]; then
                hosts=${line//:/ }
                nc -z $hosts >> testoutput.txt 2>&1

to:
Code:
        if [ ! -z "$line" ]; then
                hosts=${line//:/ }
                nc -z $hosts 2>&1 >> testoutput.txt

# 11  
Old 06-02-2014
sknovice,
you seem to verify Oracle RAC network interfaces,
so why don't you just use the tool Oracle provides?
Assuming GI is already installed:
Code:
cluvfy comp nodecon -n node1,node3 –i eth0

or
Code:
cluvfy comp nodecon -n all

Where node1, node2, noden are your cluster nodes (all = all cluster nodes).

Check the official documentation for more details.
# 12  
Old 06-02-2014
I just used them as sample only.
one of the host i am using is www.hotmail.com:53 and www.amazon.com:25 etc.

---------- Post updated at 05:18 AM ---------- Previous update was at 05:17 AM ----------

---------- Post updated at 05:22 AM ---------- Previous update was at 05:18 AM ----------

Hello Don,

That's not working as well, it's creating a file named 1 with no data and creating another file testoutput.txt with only succeeded one's not failed one's.

please advice.

code :
Code:
#!/bin/bash
#read the file line by line

cd "$1"
cat testping.txt | while read line
do
        # check if there are no blank lines
        if [ ! -z "$line" ]; then
                hosts=${line//:/ }
                nc -zv $hosts 2>1 >> testoutput.txt
        fi
done


Last edited by sknovice; 06-02-2014 at 09:02 AM.. Reason: Sorry , I copied the old source, I am using -zv instead of -z
# 13  
Old 06-02-2014
Compare what you have posted to what Don Cragun proposed. And I do not understand why you refuse to use the -v option.
# 14  
Old 06-02-2014
Hello Rudic,

Sorry, I copied old code accidently, I am using -zv only.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Establishing connectivity between two servers

I am trying to establish passwordless connectivity between server A and server B, but unsuccessfuly, because I beleive two issues. the first one is that on both servers, it is not possible to use root to login, it only allows to connect using a user (any) them su - root, which in turns I am able... (1 Reply)
Discussion started by: fretagi
1 Replies

2. Shell Programming and Scripting

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... (9 Replies)
Discussion started by: Fr3dY
9 Replies

3. HP-UX

Network Connectivity Issues

Newbie with UNIX here. Currently troubleshooting a UNIX terminal we have. I determined it to be bad and swapped it out with a known good terminal. I went in and changed the IP address and host name to reflect the old terminal. Although now there is no connectivity. I swapped out the NIC... (1 Reply)
Discussion started by: kevinlord190
1 Replies

4. Shell Programming and Scripting

Help with shell script to check the tcp network connectivity between server

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)
Discussion started by: sknovice
8 Replies

5. IP Networking

Ftp connectivity between two UNIX servers

Hi All I am having issues using ftp between a solaris 10 server to a HP-UX 11.31 server, but from the solaris server to the hp-ux I am able to ping. This is what I have done so far: in the solaris server: root@MPCRS01 # svcs -a | grep ftp online Jul_26 svc:/network/ftp:default... (12 Replies)
Discussion started by: fretagi
12 Replies

6. AIX

aix tcp wrappers hosts.allow hosts.deny?

hi all just installed the netsec.options.tcpwrapper from expansion pack, which used to be a rpm, for my aix 6.1 test box. it is so unpredictable. i set up the hosts.deny as suggested for all and allow the sshd for specific ip addresses/hostnames. the tcpdchk says the hosts allowed and... (0 Replies)
Discussion started by: wf201626
0 Replies

7. IP Networking

Connectivity problem in two servers.

HI I have made a connection with external server which is also UNIX. I was tryign connectivity with this by telnet which fails and ping i sshowing socket is alive and traceroute tells the asterisk astersik:traceroute to 153.88.182.28 (153.88.182.28), 30 hops max, 8080 byte packets 1 * * * 2 *... (1 Reply)
Discussion started by: nixhead
1 Replies

8. Solaris

connectivity between servers

We have two servers A and B (both running Solaris 10) out of which one is application server and the other is database server. The two servers faced certain network issues and the two servers were temporarily disconnected.this happened around 5AM GMT monday.Can anyone suggest some log files or... (2 Replies)
Discussion started by: asalman.qazi
2 Replies

9. IP Networking

Need to check the connectivity between 2 servers

Hi All, I need an automation script to check the connectivity between 2 UNIX servers. Could anybody please help in this regards? regards, janardhan (1 Reply)
Discussion started by: rjanardhan83
1 Replies

10. IP Networking

ip network connectivity with novell

Hi, I would like to know how i can setup my unix computer to connect to novell. Anybody any idea? (5 Replies)
Discussion started by: edw1ns
5 Replies
Login or Register to Ask a Question