Im having problem with the exscript, i want to ssh to my cisco switches, but im having some trouble
I wrote 2 scripts,
with this one I dont have any problem, I can change the default gateway just by running the script and entering the user and password:
from Exscript.util.interact import read_login
from Exscript.protocols import SSH2
account = read_login()
enter code here`conn = SSH2()
conn.connect('192.168.86.12')
conn.login(account)
conn.execute('conf t')
conn.execute('no ip default-gateway')
conn.execute('ip default-gateway 192.168.68.10')
print "Response was:", repr(conn.response)
conn.send('exit\r')
conn.close()
But the problem comes here. I want to make it automatic, I dont want to enter the user and password by hand. So I wrote this script,
from Exscript.util.interact import read_login
from Exscript.protocols import SSH2
#account = read_login()
conn = SSH2()
conn.connect('192.168.86.12')
conn.login('user','password')
conn.execute('conf t')
conn.execute('no ip default-gateway')
conn.execute('ip default-gateway 192.168.68.10')
print "Response was:", repr(conn.response)
conn.send('exit\r')
conn.close()
But it gives me this error output..
Traceback (most recent call last):
File "nn.py", line 7, in <module>
conn.login('user','password')
File "/usr/local/lib/python2.7/dist-packages/Exscript-DEVELOPMENT-py2.7.egg/Exscript/protocols/Protocol.py", line 591, in login
with self._get_account(account) as account:
File "/usr/local/lib/python2.7/dist-packages/Exscript-DEVELOPMENT-py2.7.egg/Exscript/protocols/Protocol.py", line 567, in _get_account
account.__enter__()
AttributeError: 'str' object has no attribute '__enter__'
ps: I have tried also with paramiko, but it doesnt allow me to run multiple commands.