ssh keepalive

L

loial

I have a problem with a ssh connection in python

I get the error

'NoneType' object has no attribute 'exec_command'

I am thinking that maybe the ssh connection is timeing out.

Since I have no control over the configuration of the ssh server(which
is AIX 5.23), is there anything I can do in python to ensure that the
ssh session does not timeout?
 
L

Lie Ryan

I have a problem with a ssh connection in python

I get the error

'NoneType' object has no attribute 'exec_command'

I am thinking that maybe the ssh connection is timeing out.

Since I have no control over the configuration of the ssh server(which
is AIX 5.23), is there anything I can do in python to ensure that the
ssh session does not timeout?

No, it's a NoneType object (i.e. your variable contains None)
Show us a bit of your code, so we can see why is None there.

My guess is that you're trying to perform something on a function that
does things in-place and doesn't return anything (e.g. list.append,
list.sort)
a = [1, 3, 4, 2]
a = a.sort()
print a
[None, None, None, None]
# should be
a = [1, 3, 4, 2]
a.sort()
print a
[1, 2, 3, 4]
 
L

Lie Ryan

a = [1, 3, 4, 2]
a = a.sort()
print a
[None, None, None, None]

*That* would be really odd. The last line should be just a singel
`None` and not a list. :)

Ciao,
Marc 'BlackJack' Rintsch

Ah yeah, I originally intended to give a list of list example, but
changed mind and forgot to change that last line.
 
L

loial

<<Show us a bit of your code, so we can see why is None there.>>

def command ( self , command ) :
""" process requested command through ssh """
print command
if not self._connected :
return False , "No SSH connection available"
try :
stdin , stdout , stderr =
self._ssh.exec_command( command )
remoteStdOutContent = stdout.readlines()
remoteStdErrContent = stderr.readlines()
if remoteStdErrContent != [] :
return False , '\n'.join(remoteStdErrContent)
return True , '\n'.join(remoteStdOutContent)
except paramiko.SSHException , e :
# provide socket error reason back
return False , str(e)
 
G

Gabriel Genellina

<<Show us a bit of your code, so we can see why is None there.>>

Still not enough.
From your first post, the error was:
'NoneType' object has no attribute 'exec_command'
def command ( self , command ) :
""" process requested command through ssh """
print command
if not self._connected :
return False , "No SSH connection available"
try :
stdin , stdout , stderr =
self._ssh.exec_command( command )

So you'll have to analyze how (and when) self._ssh might become None. This
function just *uses* self._ssh - look for some other places where
self._ssh is assigned to (or perhaps, deleted, if there is a class
attributes set to None).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top