[paramiko] putting ssh.connect in a loop
Eric Noulard
eric.noulard at gmail.com
Tue Nov 24 06:47:42 PST 2009
2009/11/24 Ezra Taylor <ezra.taylor at gmail.com>:
> Hello Eric:
> I did reach the first host. The output is below.
>
>
>
> Traceback (most recent call last):
> File "./cpkeys.py", line 19, in ?
> ssh.connect("%s" %(i),username='root',password='imgoingblind')
> File "build/bdist.linux-i686/egg/paramiko/client.py", line 283, in connect
> File "<string>", line 1, in connect
> socket.error: (113, 'No route to host')
The error seems that the host your are trying to connect to is unreachable.
You should try/catch your inside loop call to ssh.connect(...)
for this kind of error.
Many python libraries do through Exception in "exceptionnal" conditions,
SSHClient.connect do so as well:
http://www.lag.net/paramiko/docs/paramiko.SSHClient-class.html#connect
If you want to make your code robust you should include exception handling.
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
More information about the paramiko
mailing list