Solved

how to use script to manage telnet session

Posted on 1997-10-17
5
361 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

863 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now