Solved

how to use script to manage telnet session

Posted on 1997-10-17
5
364 Views
Last Modified: 2013-12-23
how to use telnet in a Unix script?
I wish to insert telnet commands in a telnet session using a script to both open the telnet session and insert the telnet commands.(redirection doesn't work)
0
Comment
Question by:gaddish
  • 3
5 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1582719
Do you have
man expect
on your system?
0
 
LVL 5

Accepted Solution

by:
n0thing earned 100 total points
ID: 1582720
Hi,

  Here's a sample script on how to use telnet in a script.
This script will simply log in a system & logout.
  Hope this's what you need. Another choice is to install expect
like ozo said, much more powerfull scripting capability.

Regards,
Minh Lai

#!/bin/sh
# Telnet to host and logout
# Usage: stelnet hostname
#
# If ping reachable (Under Solaris 2.5.x)
if ping $1 3
then
{
echo john          # send login
sleep 2            # wait 2 seconds for answer
echo john_passwd   # send passwd
sleep 2
echo logout        # logout of the system
} | telnet $1
fi

0
 

Author Comment

by:gaddish
ID: 1582721
HI n0thing,
Thank you for your answer.I guess I wasn't clear enough about my question, though. My problem is not how to establish a telnet session using a script, but how use a script to send telnet commands and parameters once I'm in the session already.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1582722
n0thing's method should work for sending commands too,
assuming those commands can be sent blindly.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1582723
Another way to execute commands on a remote system is with rsh.
Or, if you have expect (or want to install it) it can be used to
conduct a dialog with an interactive telnet progam.
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question