The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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-26-2006 01:38 AM
Test Ports By_Jam UNIX for Dummies Questions & Answers 3 10-31-2006 05:14 AM
determining open ports matrixmadhan UNIX for Advanced & Expert Users 7 07-18-2005 03:17 AM
How To Open Ports in RedHat ? Sirius Linux 7 09-06-2003 08:48 AM
closing open ports LowOrderBit Security 10 09-28-2001 01:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-14-2008
liketheshell liketheshell is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 21
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
  #2 (permalink)  
Old 02-14-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
Quote:
Originally Posted by liketheshell View Post
I've searched the thread and couldn't find anything that is remotely similar.
something similar.
  #3 (permalink)  
Old 02-15-2008
uvrakesh uvrakesh is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 75
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0