Help with connectivity test using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with connectivity test using shell script
# 1  
Old 08-13-2010
Java Help with connectivity test using shell script

I want to test connectivity between different servers with my server using information as IP and port only.
I have Name,IP List and port in one file. Please help how i can test connectivity is successful or not?

File format will be:
Name1,127.0.0.1,80
Name2,127.0.0.2,8080

Output could be
Name1, Successful
Name2, Unsuccessful

I have prepare the code which uses curl and execute complete URL which is as follows:

##############code####################
Code:
for url in $(awk -F"," '{print $3}' cp_urls.txt)
do
  curl -s -o "/dev/null" $url
  if [ $? -eq 0 ] ; then
    echo "$url = running"
  else
    echo "$url = not running"
  fi
done

################emd####################

But i don't want to test connectivity with complete url as it provides the hit to url,but using IP and port number specified in file.
Please suggest.

Last edited by pludi; 08-13-2010 at 02:21 AM.. Reason: code tags, please...
# 2  
Old 08-13-2010
You can probably use

Code:
telnet <IP> <port no>

If you see message "connected to host" then the port is listening. If it says "unable to connect" then the port is not listening.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. 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

2. UNIX for Dummies Questions & Answers

Test connectivity to IP/port

I want to test the connectivity to an IP with Port number = xxxx. I only know telnet can do it. For example, telnet <IP> <port>. But I don't have telnet installed (no package) on my Red Hat Linux server. I searched the Internet and realized that I will need either the installation media which... (2 Replies)
Discussion started by: learnix
2 Replies

3. Shell Programming and Scripting

Test shell script (PROBLEM)

Dears , kindly I wanna do test for one KSH script to know how is it working , the problem that I'm facing is whenever put "sh -x ./my_script.sh" the output seems very long & although I tried to to redirect it to files as it shown , but it failed :eek: :- sh -x ./my_script.sh >... (2 Replies)
Discussion started by: arm
2 Replies

4. Solaris

Sybase Connectivity Check through Shell Script

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)
Discussion started by: nandha2387
0 Replies

5. AIX

telnet to test connectivity

From a Windows command prompt, when I want to test whether an IP and port is open to a connection I can use telnet: telnet 1.2.3.4 5050 ..tests whether I can connect to port 50 on host 1.2.3.4. What is the correct context to do a similar test from an AIX console? Thanks! (1 Reply)
Discussion started by: landog
1 Replies

6. Shell Programming and Scripting

-a test in shell script

I need clarification in -a test. If say, in test -a left expression is not present but the right expression is present, do the shell will consider the left expression true and evaluate the right expression? For example: if ] then rm -f ${file} fi Is this test condition... (7 Replies)
Discussion started by: jatanig
7 Replies

7. Shell Programming and Scripting

test script to identify SHELL

I am new to BASH and writing a small script to identify the SHELL . #!/bin/bash BASH='/bin/bash' KSH='/bin/ksh' if then echo "it's Bash" else echo "it's not Bash" fi $ bash -x a.sh + BASH=/bin/bash + KSH=/bin/ksh + '' a.sh: line 4: where am I missing . PLease advice . (10 Replies)
Discussion started by: talashil
10 Replies

8. Shell Programming and Scripting

Test for shell interpreter at beginning of script

What would be the best way or method to determine or test for the shell interpreter at the beginning of a script in the event one shell is not available? If I use the following: #!/bin/bash and /bin/bash is not available, then use I'd like to use /bin/ksh if it is available. #!/bin/ksh (8 Replies)
Discussion started by: nck
8 Replies

9. Shell Programming and Scripting

need help with test condition in shell script

I'm new to scripting and I need help with a bourn shell script. What i'm trying to do is a test condition where "if the time is within 2 hours, it's true" and so on. The time is in the following format DATE=`/bin/date +"%Y%m%d%H%S"` for example, 20060907152000. So, what the script first... (9 Replies)
Discussion started by: pieman8080
9 Replies
Login or Register to Ask a Question