02-14-2008
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
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
hi all
1) how to determine available ports in a box (solaris)
do i have to go for a netstat on all the ports?
2) how to block a particular port for a particular type of connection.
Any help would be greatly appreciated
Thanks (7 Replies)
Discussion started by: matrixmadhan
7 Replies
2. UNIX for Dummies Questions & Answers
Hi,
Which command or file to use to test the ports of a server?
Thanks.... (3 Replies)
Discussion started by: By_Jam
3 Replies
3. Shell Programming and Scripting
Hi friends,
I'm newbie to shell script. I wanted to create a shell script which able to write a result for all the telnet connection status. For example, from this machine I want to test the telnet connection (total 100+ servers) with this machine.
Any idea how to write this shell script?... (16 Replies)
Discussion started by: yhcheong
16 Replies
4. UNIX for Advanced & Expert Users
This may seem like a silly question, but how do you iptable firewall an NFS Server tightly? I tend to use Samba much more heavily which is easy, the ports are clearly defined... but on NFS it is relying on portmapper (yuck).... so the ports may change... Is it possible to fix the NFS Server ports,... (2 Replies)
Discussion started by: humbletech99
2 Replies
5. UNIX for Dummies Questions & Answers
just a quick question:
a. whats the simplest command to check open port and the corresponding services?
example:
bash-2.05# netstat -an | grep LISTEN
*.199 *.* 0 0 49152 0 LISTEN
*.8989 *.* 0 0 49152 ... (1 Reply)
Discussion started by: lhareigh890
1 Replies
6. UNIX for Dummies Questions & Answers
Alright... this question comes from the fact that I'm trying to setup postfix to relay messages to Office 365 SMTP but its giving me connection refused... I read that if you have doubts if your port is open or not you should telnet to them so thats what I did.
This is a Red Hat 6.3 box.
My... (4 Replies)
Discussion started by: RedSpyder
4 Replies
7. UNIX for Dummies Questions & Answers
Hello,
I need to test telnet connections using port number for few hosts.
Could you please help me?
Thanks !! (1 Reply)
Discussion started by: skhichi
1 Replies
8. Shell Programming and Scripting
Hi
I'd like to check that a bunch of firewall rules have been applied and, therefore, want to write a script that basically does the following:
telnet serverA port1
telnet serverA port2
telnet serverB port1
telnet serverB port2
I would just compile the list in excel and run it as a... (2 Replies)
Discussion started by: jibberish
2 Replies
9. Shell Programming and Scripting
Hi,
I do a telnet to a single server using command :telnet tibserver001 9640
The output i get is :
Trying 10.19....
Connected to tibserver001
However i need to put all the servers in a single file and get the output to see if the server is connected or not.
#! /bin/bash
telnet... (3 Replies)
Discussion started by: samrat dutta
3 Replies
10. Shell Programming and Scripting
Hello all,
I have a task to patch red hat servers and some servers have a corrupted rpm database and return the error:
Error: rpmdb open failed
I know how to fix this when it occurs. What I'm hoping to do is scan a list of servers by IP and report back which server have this error.
... (6 Replies)
Discussion started by: greavette
6 Replies