Solved

how to use script to manage telnet session

Posted on 1997-10-17
5
367 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
WARNING:   If you follow the instructions here, you will wipe out your VTP and VLAN configurations.  Make sure you have backed up your switch!!! I recently had some issues with a few low-end Cisco routers (RV325) and I opened a case with Cisco TA…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Suggested Courses
Course of the Month5 days, 15 hours left to enroll

626 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