How to disconnect telnet prompt with port no in script.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to disconnect telnet prompt with port no in script.
# 1  
Old 08-09-2012
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
=========================================
Code:
 telnet ipaddress portno [in this case 25]
Trying 216.82.253.227...
Connected to ipaddress
Escape character is '\377'.
220 server-9.tower-170.messagelabs.com ESMTP
quit <<<< (Manually entered quit)
221 server-9.tower-170.messagelabs.com
Connection closed by foreign host.

The above is one of the example how can i make it same thing to go in script
Please help me Gurus am new to scripting
Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by Corona688; 08-09-2012 at 06:09 PM..
# 2  
Old 08-09-2012
You can try redirecting /dev/null into it. telnet hostname port </dev/null

It should connect, try and read input from /dev/null, get EOF, and quit.

telnet may not really be the tool for the job here, however! It's an interactive program and very difficult to automate. netcat (nc) would be better suited if you can get it, it's designed to be noninteractive from the first.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 08-09-2012
Thanks Corona ,Will try your suggestion Smilie
# 4  
Old 08-14-2012
Thanks a ton Corona ,it worked Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

SSH and telnet long delay to recieve prompt.

Hi guys. You'd have to excuse me a bit, as I'm a noob. I really try to avoid asking questions and do research for whatever linux issues that may arise. I am experiencing a long wait for the shell to come up when I ssh or telnet into a Sunos 5.10 environment. It takes 70 seconds to give me... (12 Replies)
Discussion started by: gpenco
12 Replies

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

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

4. Shell Programming and Scripting

how do I infinite loop (reconnect) to auto disconnect telnet server

I want the text based Star Wars movie at towel.blinkenlights.nl to loop infinitely. It plays the movie and then disconnects my session? Can anyone think of a way to make my unix machine automatically reconnect over and over? EDIT no commands are required are the connection its just in and... (3 Replies)
Discussion started by: herot
3 Replies

5. UNIX for Dummies Questions & Answers

Auto-exit from telnet prompt

Hi, Hope all your are doing well. Need a suggestion from you. I am writing an automated shell script that will effectively check the telnet connectivity with different backends from present deployment server. Ideally, this script reads each backend hostname from a configuration file and fires... (4 Replies)
Discussion started by: bhaskar_m
4 Replies

6. Shell Programming and Scripting

Net::Telnet (match prompt)

Hi, The code below is used to telnet to list of devices and configure them. The program executes in this manner: 1. telnet to the first device in file.txt 2. one the telnet command is executed a "press any key to continue" prompts. 3. once a return key is executed it ask for username,... (1 Reply)
Discussion started by: sureshcisco
1 Replies

7. Shell Programming and Scripting

how do i access db2 instance via telnet command prompt

Hi I have a perl script code in which connecting with db2 database and doing some process. My perl script code and db2 database server present in the same unix server. I am connecting and executing perl script code via windows telnet. Now my question is i could not able to connect db2 server... (4 Replies)
Discussion started by: solo123
4 Replies

8. Shell Programming and Scripting

Telnet in command prompt

Hi, i have typed telnet yahoo.com 80 in command prompt it displays as a blank command prompt page titling as Telnet Yahoo.com Other than that i am not able to get anything. can anyone sort me out the reason for this (12 Replies)
Discussion started by: satheeshkr_cse
12 Replies

9. Shell Programming and Scripting

Telnet IP and Port Script

Hi, 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... (6 Replies)
Discussion started by: asou
6 Replies

10. 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
Login or Register to Ask a Question