Telnet IP and Port Script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Telnet IP and Port Script
# 1  
Old 11-02-2009
Telnet IP and Port Script


I would like to create a simple script that will telnet a number of IP and Ports one after the other to confirm connectivity to those addresses.

I don't need to log on, just output to a file what the response is, i.e Escape Character, connectivity refused etc.

Complete newbie to shell scripting so ideally something that isn't to complex.

Any ideas on where to start?
# 2  
Old 11-02-2009
# 3  
Old 11-03-2009
I have looked through the search results and have the following based on an existing script.

set -vx
read line < portTest
for i in $line;
# check for open ports #
connTest=`echo " " |telnet "$i"`
if [ "`echo $connTest | awk '{ print $3 }` " = "Connected" ]
echo "$connTest port is up"
echo "$connTest port is down"

This refers to a file "portTest" which looks like this: 2001#

If I echo the variable $i earlier in the script than the telnet command it prints the whole value up to #, but when it sends the telnet request the port is not included.

Any ideas why?
# 4  
Old 11-03-2009
look man:nc
# 5  
Old 11-03-2009
Is this refering to Netcat?

I get nothing when entering that. I don't believe it is installed on my server.
# 6  
Old 11-03-2009
Yes it's refering to's damage, it's a good tool.
What's your system ???
# 7  
Old 11-03-2009
I am running this on a Solaris 5.10 host which I have limited rights to.

I know this is not pretty / the right way of doing it. But my scripting knowledge (as you can see) is very limited and I just want something quick and dirty.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell Script to test telnet connection using port

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

2. IP Networking

telnet for port 5433 is not working while it works for port 22

Hi, I am trying to set up a dev environment and I have Ubuntu server ( and a CentOS VM ( on this. On the CentOS I have a program running on port 5433. Now my problem is that I am unable to telnet this port from another Windows server whereas I can telnet port 22 from... (5 Replies)
Discussion started by: rishav
5 Replies

3. UNIX for Dummies Questions & Answers

How to disconnect telnet prompt with port no in script.

Hi Gurus, I am trying to write a script for checking the status of linux servers by connecting via telnet with port no but to terminate i have to manually type "quit" .how can i terminate the telnet session in script itself.For E.g ========================================= telnet ipaddress... (3 Replies)
Discussion started by: kapil514
3 Replies

4. Red Hat

telnet port 23

My linux version is 2.6.18-194.e14 (Oracle enterprise linux). Could you please tell me how to enable telnet on the server. When I try to connect the server through another pc using telnet it is throwing error. Connecting To <ip address>...Could not open connection to the host, on port 23.... (3 Replies)
Discussion started by: oradba_arun
3 Replies

5. Cybersecurity

Can't telnet to port 25 on the host.

Hi, we have recently setup a new UNIX server with solaris 10 and I am having issue with with SMTP/sendmail. telnet localhost 25 --- works telnet 25 -- does not work. # telnet 25 Trying telnet: Unable to connect to remote host:... (1 Reply)
Discussion started by: esmgr
1 Replies

6. Windows & DOS: Issues & Discussions

Telnet to a serial port

Hello all. I have an old computer with M$-DOS 7. I want to use it like a dumb terminal, with telnet. I need to connect it to my desktop These are my questions: How can i configure the serial port on dos? How can i telnet form dos to the serial port? How can i set up a telnet server on the... (12 Replies)
Discussion started by: mghis
12 Replies

7. AIX

Telnet to port

can some one help me ? what happens when we telnet to a port ? example telnet 192.168.0.xx 1234 where 1234 is a port number Thank you (5 Replies)
Discussion started by: anwesh
5 Replies

8. UNIX for Advanced & Expert Users

telnet on specific port??

Hi all, I have a problem. I have machine names and their IP addresses in /etc/hosts file. My application does telnet on that machine host name. The application does not uses IP address for tenet. It will fetch the host name from /etc/hosts file. Now the telnet server runs on customized port.... (6 Replies)
Discussion started by: zing_foru
6 Replies

9. Solaris

disabled telnet now need port 23 or port 22

we disabled telnet on solaris 9 via previous a thread. We use CMS (call management system) supervisor which used port 23 (telnet). We cannot use telnet via local directive and it was shut down as stated when we shut down telnet in the inetd file. I cannot now log into the CMS box since port 23 is... (3 Replies)
Discussion started by: panzerkw
3 Replies

10. IP Networking

block telnet to specific port

Hello All I am running redhat linux 7.2 and would like to know how i can block telnetting to a specified port . say for example i would like to block telnet acesses to port 80. regards Xiamin (5 Replies)
Discussion started by: xiamin
5 Replies
Login or Register to Ask a Question