Telnet of multiple server and ports


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Telnet of multiple server and ports
# 1  
Old 07-09-2018
Telnet of multiple server and ports

Hi,
I do a telnet to a single server using command :telnet tibserver001 9640
The output i get is :
Code:
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.
Code:
#! /bin/bash
telnet tibserver001 9640 > output.log
telnet tibserver004 9642 >>output.log

The above does not seem to work. Is there a better way to script this ?

regards
Sam

Last edited by Don Cragun; 07-09-2018 at 03:31 PM.. Reason: Add missing ICODE tags.
# 2  
Old 07-09-2018
What operating system are you using?

In what way does it not seem to work?

What output do you get from running ls -l output.log before you run your script?

What output do you get on the screen when you run your script?

What output do you get from running ls -l output.log after you run your script?

What are the contents of output.log after you run your script?
# 3  
Old 07-09-2018
Hi,
Using Linux 5 . A change in the script which will take a input file which has servername,port. As telnet was not going into the next item in the file, i used curl instead of telnet. This works. However i am not able to get the output of the script write into the log file properly. I will have to see if i can get the output which only displays in the console be printed in the output.log file.

Input to the file is : serverlist.txt
Code:
tibserver001,9640
tibserver004,9642

Script is :trytelnet.sh -->
Code:
#!/bin/bash

if [[ $# -ne 1 ]]; then
 echo " $0 server list"
exit 1
fi

serverlist=$1
OUT=output.log
rm $OUT > /dev/null 2>&1
while IFS=, read HOST PORT
do
        echo -e "\n\n======================================================================================\n\n"
        echo Working on $HOST
        echo "Checking $HOST on Port $PORT"
        curl $HOST:$PORT --verbose >> $OUT
        echo -e "\n\n======================================================================================\n\n"
done < $serverlist

Execution is :
Code:
./trytelnet.sh serverlist.txt




Moderator's Comments:
Mod Comment Please use CODE tags consistently as required by forum rules!

Last edited by RudiC; 07-09-2018 at 06:06 PM.. Reason: Added missing CODE tags.
# 4  
Old 07-09-2018
telnet might be eating up the rest of your input file on stdin.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help grep multiple ports in a file.

I wish to grep for an entry in a file if it contains and does not start with #, Listen 443 or Listen 9443 Below is what helped me get Listen 443 but how can I tweak the below command to also include Listen 9443 port ? Note: Listen 8443 or Listen 4438 should fail in the grep. ... (2 Replies)
Discussion started by: mohtashims
2 Replies

2. UNIX for Beginners Questions & Answers

Check telnet port multiple server

Dear Team, I want to check multiple linux server to check port open. eg. 192.168.1.12 80,192.168.1.12 443 Please provide script for that? (8 Replies)
Discussion started by: pradeep1807
8 Replies

3. Solaris

Solaris 11 ssh on machine with multiple Ethernet ports

I have a server with 6 Ethernet ports. 4 are the the motherboard based 1 GBE ports and 2 are 10 GBE ports on NICs. I have set these all up with static IP addresses and use the standard /etc/nsswitch.files. My IP addresses are net0 192.168.1.82 net1 192.168.2.82 and so on till net5... (4 Replies)
Discussion started by: ashlaw
4 Replies

4. Red Hat

Ports opened on remove server

Hi Gents, I know we can use nmap & telnet to find remove server ports, any other way for the same ? thanks (1 Reply)
Discussion started by: heman96
1 Replies

5. UNIX for Dummies Questions & Answers

I have firewall rules to open ports, why telnet refuses connection?

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

6. Shell Programming and Scripting

How to auto telnet the server from another server using script

Hi All, I have a problem with auto telnet script, but I want to tell u something a) I am only a member access on the server, so not able to access 'root' account b) not able to install any software on server 3) On server, there is not install 'except' I have to write a script, which is ran... (0 Replies)
Discussion started by: atul9806
0 Replies

7. Linux

vsftpd on multiple ports

I have a ftp server on ssl talking on port 21, i would like to allow another port to acess the same server. I am not sure if its possible or not and if its how can i do that? (2 Replies)
Discussion started by: shehzad_m
2 Replies

8. Cybersecurity

check ports on server

Hi All, I've been using this to verify if ports is open on a server. For example I would like to check port 5887, "telnet ip.of.server 5887" using on dos. If there's response on it then I can say it's open, if not then it's close. Is that assumption accurate? Thanks for any comments you... (4 Replies)
Discussion started by: itik
4 Replies

9. IP Networking

domain linux server, open ports?

Hi all - i currently run a domain strifex.net. This domain has a dedicated IP address and in having that, should be able to run a ventrilo VoIP server from it. I uploaded all the needed files etc... and am able to connect to it, if and only if i enable DMZ to my local machine - then i am able to... (1 Reply)
Discussion started by: ccfc1986
1 Replies

10. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: liketheshell
2 Replies
Login or Register to Ask a Question