I have a script that reads from a CSV file to ssh to devices. I am trying to run exec.command to read some info and place in a variable. When i run it, i receive an exception error on resource shortage. I've googled it and have tried a couple of things (sleep etc.) but cant seem to figure it out. Both script and error listed. Any help would be appreciated.
### script ###
### script ###
with open(r'Customer_Info.csv', 'r') as f:
for line in f:
router = {}
router_line = line.split(',')
router = {
'ip': router_line[11],
'username': router_line[21],
'password': router_line[22],
}
if valid_ip(router['ip']) and router['password'] and router['username']:
#Create an SSH client
client = paramiko.SSHClient()
#Make sure that we add the remote server's SSH key automatically
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
#Connect to the client
client.connect(router['ip'], username=router['username'], password=router['password'], allow_agent=False, look_for_keys=False)
#Create a raw shell
shell = client.invoke_shell()
[b]#Grab hostname of device
stdin, stdout, stderr = client.exec_command('sh run | i hostname')
mystring = stdout.read()
print (mystring)
hostname = mystring[9:][/b]### Error ###Error:Secsh channel 1 open FAILED: : Resource shortage
Traceback (most recent call last):
File "V:\Workspace\Scripting\Python Scripts\Sandbox\HNS_VPN-AutoConfig2.py", line 157, in <module>
stdin, stdout, stderr = client.exec_command('sh run | i hostname')
File "C:\Users\jkey\AppData\Local\Programs\Python\Python36-32\lib\site-packages\paramiko\client.py", line 480, in exec_command
chan = self._transport.open_session(timeout=timeout)
File "C:\Users\jkey\AppData\Local\Programs\Python\Python36-32\lib\site-packages\paramiko\transport.py", line 767, in open_session
timeout=timeout)
File "C:\Users\jkey\AppData\Local\Programs\Python\Python36-32\lib\site-packages\paramiko\transport.py", line 902, in open_channel
raise e
paramiko.ssh_exception.ChannelException: (4, 'Resource shortage')
