[nsp] Cisco commands automatically sent

Todd, Douglas M. DTODD@PARTNERS.ORG
Fri, 9 Aug 2002 13:36:22 -0400


 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can use expect: example here (quick and dirty)

command usage: ./autotel myswitch 
#note myswitch and hostname prompt must match in this case.. 

#!/usr/local/bin/expect -f
## call with autotel host username password

set host [lindex $argv 0]
set rcfile [open ~/.autotel/pwd  r ] #Opens file for password pwd
file has user <cr> password 
gets $rcfile user
gets $rcfile pass
spawn telnet  "$host" 
expect "Username:"
send "$user\r"
expect "Password:"
send "$pass\r"
expect "$host>"
send "en\r"
expect "Password:"
send "blahblahblah\r"
interact


==DMT>
- ----SIGNAURE-------
Douglas M. Todd, Jr.
CCNA, CCNP, CIT
Network Engineering
Partners Health Care
Building 149
149 13 Street
Charlestown, MA 02129-200
Tel: 617.726.1403
Email: dtodd@partners.org
- --------------------------------------------------------------------
PGP Finger Print: 9429 CAE3 B2D1 C2E1 DFBC  E7A6 E90A 9BE5 C7B6 47BC
Key available via email.
Verisign S/N: 3ff65cdf58b9dceda004baeed49e16cf
https://digitalid.verisign.com/services/client/index.html

> -----Original Message-----
> From: Tejal Shah [mailto:tejal.shah@surat.iqara.net]
> Sent: Friday, August 09, 2002 12:08 PM
> To: Tim Franklin; odusseus; cisco-nsp
> Cc: odusseus; cisco-nsp
> Subject: Re: RE: [nsp] Cisco commands automatically sent
> 
> 
> Use perl module Net-Telnet-Cisco or rcmd 
> 
> with regards
> Tejal Shah
> 
> ----- Original Message -----
> From: "Tim Franklin" <tim@colt.net>
> Date: Friday, August 9, 2002 8:49 pm
> Subject: RE: [nsp] Cisco commands automatically sent
> 
> > > I would like to know if it is possible to write a 
> > program on a
> > > Unix box where it could automatically run some 
> > commands on a
> > > cisco devices (7200 series and 3500XL) like:
> > > 
> > > enable
> > > conf t
> > > int fa0/1
> > > shut
> > > end
> > 
> > Expect, if nothing else, will do what you want - you 
> > can essentially control the telnet session from within 
> > a script.  You can do much the same thing from Perl, 
> > Python, or some other scripting language of your 
> > choice - open a telnet connection to the box, log in 
> > and issue commands.
> > 
> > The danger is that your script will probably need to 
> > contain login information for the router, and in your 
> > example above the enable password.
> > 
> > Regards,
> > Tim.
> > 
> > --
> > Tim Franklin          ____________
> > Project Engineer      \C/\O/\L/\T/   EN&S -
> > T: +44 20 7863 5714    V  V  V  V  IP Services
> > F: +44 20 7863 5876
> > 
> > 
> > _______________________________________________
> > cisco-nsp mailing list  real_name)s@puck.nether.net
> > http://puck.nether.net/mailman/listinfo/cisco-nsp
> > archive at http://puck.nether.net/pipermail/cisco-nsp/
> > 
> 
> 
> Go To http://www.iqara.net
> 
> _______________________________________________
> cisco-nsp mailing list  real_name)s@puck.nether.net
> http://puck.nether.net/mailman/listinfo/cisco-nsp
> archive at http://puck.nether.net/pipermail/cisco-nsp/

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0

iQA/AwUBPVP9MwgiZycqTvq3EQJH+wCfVMU96VASpgxLpdeszI3U7DB4nV0AmwXl
0re8GXdnc1ZgY8QARnbVjBPp
=dAps
-----END PGP SIGNATURE-----