The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Open Ports on System aldowsary AIX 2 11-25-2006 09:38 PM
Test Ports By_Jam UNIX for Dummies Questions & Answers 3 10-31-2006 01:14 AM
determining open ports matrixmadhan UNIX for Advanced & Expert Users 7 07-18-2005 12:17 AM
How To Open Ports in RedHat ? Sirius Linux 7 09-06-2003 05:48 AM
closing open ports LowOrderBit Security 10 09-27-2001 10:43 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-14-2008
Registered User
 

Join Date: Aug 2007
Posts: 21
Stumble this Post!
Telnet script to test open ports on mult servers

Hello All,

Can somebody help me with this script. I have an output file with a list of servers ips and ports. I need to be able to run this script to list all the server ips in the outfile and find out if the port is open or not.

#!/bin/sh

IFS=#;for i in $(cat portTest);

do
# check for open ports #

connTest=`echo " " | telnet $i`

if [ "`echo $connTest | awk '{ print $3 }` " = "Connected" ]
then

echo "$connTest port is up"

else

echo "$connTest port is down"

fi
done


The output i am getting now is this

148.xxx.xx.89 44441
148.xxx.xx.92 44441
148.xxx.xx.95 44441
148.xxx.xx.98 44441
148.xxx.xx.101 44441
148.xxx.xx.104 44441
148.xxx.xx.107 44441 port is down

Can somebody pls tell me what i am doing wrong. I've searched the thread and couldn't find anything that is remotely similar. Please note i don't need to specify a username or password.

Thanks for all your help

AC
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-14-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,540
Stumble this Post!
Quote:
Originally Posted by liketheshell View Post
I've searched the thread and couldn't find anything that is remotely similar.
something similar.
Reply With Quote
  #3 (permalink)  
Old 02-14-2008
Registered User
 

Join Date: Dec 2005
Posts: 74
Stumble this Post!
Suggestion debuging script would be easeier if you add
set -vx
below #!/bin/sh

hope this will help you find you were wrong

Best Regards,
Rakesh UV
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0