Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using telnet in script to exec commands

Status
Not open for further replies.

StickyBit

Technical User
Jan 4, 2002
264
CA
Hi folks,

Is it possible to write a script that will send commands to my cisco router from my solaris box using telnet? Something like this.

!#/usr/bin/sh

telnet router<<EOF
passwd
en
passwd
config t
interface eth0
shutdown
EOF

Am I thinking correctly, or am I off key here? How would I accomplish the task?

StickyBit.
 
Hi there,

You will need something like 'expect' if you want to give commands via telnet.

If you're familiar with Perl, or even if you're not but are willing to give it a go, there's a utility module called Net::Telnet which will do what you need. I wouldn't be able to help you with 'expect', the traditional way of doing something like this, but I have used Perl before. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top