Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!goanna.cs.rmit.edu.au!news.apana.org.au!cantor.edge.net.au!news.teragen.com.au!news.access.net.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!cpk-news-hub1.bbnplanet.com!su-news-hub1.bbnplanet.com!news.bbnplanet.com!news.pbi.net!nntp1.Fresno.qnis.net!ns.qnis.net!phil From: Phil Jensen <phil@ns.qnis.net> Newsgroups: comp.unix.bsd.bsdi.misc Subject: Re: automated telnet? Date: 25 Feb 1997 07:25:44 GMT Organization: QuadraNet Internet Services Lines: 49 Message-ID: <5eu45o$k6u@nntp1.Fresno.qnis.net> References: <330E4EF3.6615@monad.net> <5eohcv$o4h$1@mark.ucdavis.edu> NNTP-Posting-Host: ns.qnis.net Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit X-Newsreader: TIN [UNIX 1.3 unoff BETA release 970202] Xref: euryale.cc.adfa.oz.au comp.unix.bsd.bsdi.misc:6095 Greg Shenaut <greg@trefoil.bogs.org> wrote: : Paul Venezia (pvenezia@monad.net) wrote: : : I'm trying to figure out the best way of automating a telnet session to : : log into a router and get certain data. I believe that expect is the : : best way to accomplish this, but the man page is a bit long-winded. Does : : anyone have an example application of expect? : : -- : : Paul Venezia - MonadNet System Administrator : : pvenezia@monad.net : : http://www.monad.net : The expect distribution has a heap of examples; plus, I recommend : the O'Reilly book on expect--I think it's called "Exploring Expect". Yup, you're right. It sells here for around $35, I think, so it won't drain your pocketbook. It's an excellent reference book, providing explanations of those heaps of examples you'll find in the tarball. I'll include a little script that automates logging into my Cisco, and typing the enable password in for me. # Clip here. #!/usr/local/bin/expect -- log_user 0 spawn telnet core1.Fresno.qnis.net # Set logging off and define the prompt. set prompt QuadraNet# expect -re "Escape character is '.*'\.(.*)Username:" send_user "$expect_out(1,string)" send "phil\r" expect "word:" send "SOMEPWHERE\r" expect "$prompt" send_user "You are now interacting with core1.Fresno -- please type your commands now.\n" send "\n" interact { "enable" {send "\rENPWHERE\r"} } I hope this is some help--it really is a piece of cake to learn. -p -- Phil Jensen QuadraNet Internet Services Manager of Network Operations http://www.qnis.net