Sponsored Content
Full Discussion: Telnet IP and Port Script
Top Forums Shell Programming and Scripting Telnet IP and Port Script Post 302367646 by asou on Tuesday 3rd of November 2009 07:14:46 AM
Old 11-03-2009
I have looked through the search results and have the following based on an existing script.

Code:
 
#!/bin/sh
set -vx
read line < portTest
OIFS=$IFS
IFS=#;
for i in $line;
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

This refers to a file "portTest" which looks like this:
139.xxx.xxx.xxx 7001#139.xxx.xxx.xxx 7011#139.xxx.xxx.xxx 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?
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

6. 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 hostname.domain.com 25 -- does not work. # telnet hostname.domain.com 25 Trying 10.122.1.111... telnet: Unable to connect to remote host:... (1 Reply)
Discussion started by: esmgr
1 Replies

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

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

9. 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 (10.16.1.92) and a CentOS VM (10.16.3.235) 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

10. 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
scanssh(1)						    BSD General Commands Manual 						scanssh(1)

NAME
scanssh -- scans the Internet for open proxies and SSH servers SYNOPSIS
scanssh [-VIERph] [-s scanners,...] [-n ports,...] [-e excludefile] addresses... DESCRIPTION
ScanSSH scans the given addresses and networks for running services. It mainly allows the detection of open proxies and Internet services. For known services, ScanSSH will query their version number and displays the results in a list. The adresses can be either specified as an IPv4 address or an CIDR like IP prefix, ipaddress/masklength. Ports can be appended by adding a colon at the end of address specification. Additionally, the following two commands can be prefixed to the address: random(n[,seed])/ The random command selects random address from the address range specified. The arguments are as follows: n is the number of address to randomly create in the given network and seed is a seed for the pseudo random number generator. split(s,e)/ The split command is used to split the address range in several unique components. This can be use to scan from serveral hosts in parallel. The arguments are as follows: e specifies the number of hosts scanning in parallel and s is the number of the host this particular scan runs on. The options are as follows: -V Causes scanssh to print its version number. -I Does not send a SSH identification string. -E Exit the program, if the file containing the addresses for exclusion can not be found. -R If addresses are generated at random, this flag causes the program to ignore excluded addresses from the exclude file. The default behaviour is to always exclude addresses. -p Specifies that ScanSSH should operate as a proxy detector. This flag sets the default modes and default scanners to detect open proxies. -h Displays the usage of the program. -n ports,... Specifies the port numbers to scan. Ports are separated by commas. Each specified scanner is run for each port in this list. The default is 22. -s scanners Specifies a number of scanners should be executed for each open port. Multiple scanners are separated by commas. The fol- lowing scanners are currently supported: ssh Finds versions for SSH, Web and SMTP servers. socks5 Detects if a SOCKS V5 proxy is running on the port. socks4 Detects if a SOCKS V4 proxy is running on the port. http-proxy Detects a HTTP get proxy. http-connect Detects a HTTP connect proxy. telnet-proxy Detects telnet based proxy servers. -e excludefile Specifies the file that contains the addresses to be excluded from the scan. The syntax is the same as for the addresses on the command line. The output from scanssh contains only IP addresses. However, the IP addresses can be converted to names with the logresolve(8) tool included in the Apache webserver. EXAMPLES
The following command scans the class C network 10.0.0.0 - 10.0.0.255 for open proxies: scanssh -p 10.0.0.0/24 The next command scans for ssh servers on port 22 only: scanssh -n 22 -s ssh 192.168.0.0/16 The following command can be used in a parallel scan. Two hosts scan the specified networks randomly, where this is the first host: scanssh 'random(0,rsd)/split(1,2)/(192.168.0.0/16 10.1.0.0/24):22,80' BUGS
At the moment, scanssh leaves a one line entry in the log file of the ssh server. It is probably not possible to avoid that. BSD
July 17, 2000 BSD
All times are GMT -4. The time now is 09:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy