ssh keepalive

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • loial

    ssh keepalive

    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?

  • Lie Ryan

    #2
    Re: ssh keepalive

    On Wed, 01 Oct 2008 00:30:59 -0700, loial wrote:
    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]

    Comment

    • Marc 'BlackJack' Rintsch

      #3
      Re: ssh keepalive

      On Wed, 01 Oct 2008 08:07:43 +0000, Lie Ryan wrote:
      >>>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

      Comment

      • Lie Ryan

        #4
        Re: ssh keepalive

        On Wed, 01 Oct 2008 10:47:28 +0000, Marc 'BlackJack' Rintsch wrote:
        On Wed, 01 Oct 2008 08:07:43 +0000, Lie Ryan wrote:
        >
        >>>>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.

        Comment

        • loial

          #5
          Re: ssh keepalive

          <<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 )
          remoteStdOutCon tent = stdout.readline s()
          remoteStdErrCon tent = stderr.readline s()
          if remoteStdErrCon tent != [] :
          return False , '\n'.join(remot eStdErrContent)
          return True , '\n'.join(remot eStdOutContent)
          except paramiko.SSHExc eption , e :
          # provide socket error reason back
          return False , str(e)

          Comment

          • Gabriel Genellina

            #6
            Re: ssh keepalive

            En Thu, 02 Oct 2008 05:26:25 -0300, loial <jldunn2000@goo glemail.com>
            escribió:
            <<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).


            --
            Gabriel Genellina

            Comment

            Working...