[Netdevicelib-checkins] CVS: netdevicelib/src/netdevicelib/examples getConfig.py,NONE,1.1
Status: Alpha
Brought to you by:
bluecoat93
|
From: <net...@li...> - 2001-08-26 20:36:54
|
Update of /cvsroot/netdevicelib/netdevicelib/src/netdevicelib/examples
In directory usw-pr-cvs1:/tmp/cvs-serv31668
Added Files:
getConfig.py
Log Message:
- add example script to get a Cisco router's running config
--- NEW FILE: getConfig.py ---
#!/usr/local/bin/python
# A simple example that downloads the running-config from a Cisco router.
# Notes:
# - Assumes that netdevicelib is in your PYTHONPATH.
# - Error checking omitted for clarity
# $Id: getConfig.py,v 1.1 2001/08/26 20:36:51 bluecoat93 Exp $
import sys
from netdevicelib.connections import ConnectionFactory
# Check the command-line arguments
if len( sys.argv ) < 4:
print "Usage: version.py device username password"
sys.exit(0)
# Create a Connection object for a telnet connection to an IOS device
conn = ConnectionFactory().createConnection( "telnet", "IOS" )
# Open the connection to the device
conn.open( sys.argv[1] )
# Login to the device. Assumes username/password login (i.e. TACACS)
conn.login( sys.argv[2], sys.argv[3] )
# Run the command on the device
lines = conn.getConfig()
# Print the output
print lines
|