0
votes

I am using paramiko package to create an SSH to my server.
I wrote the following code (part of my module) that should execute some command and return it's output.

def exec_and_get_remote_output(self, cmd, decode=True, splitlines=True, ssh_close=False):
    """
    Execute remote command and return output

    :param cmd: command to execute (string)
    :param decode: perform decoding from binary (bool)
    :param splitlines: perform splitting to get list of lines (bool)
    :param ssh_close: close SSH session after execution (bool)
    :return: command output as sting or list of lines
    """

    if CHECK_NONE(self._client):
        logger.debug('ssh client is None')
        return None

    if not self._opened:
        self.open_connection()

    chan = self._client.get_transport().open_session()
    chan.exec_command(cmd)

    logger.debug('Executed SSH command: {}'.format(cmd))

    raw_output = self.receive_output(chan)

    if decode and splitlines:
        output = self._decode_raw(raw_output)
    elif decode and not splitlines:
        output = self._decode_raw(raw_output, splitlines=False)
    else:
        output = raw_output

    logger.debug('Raw output:\n{}'.format(output))

    # Perform cleanup
    self.cleanup(chan, ssh_close)

    return output

This Code should execute some command (passed as a string) and then parse the output from the channel.
When I call this method with simple shell command I get the output as needed.
[ for example: print(self.ssh.exec_and_get_remote_output("ls"))]

Now , my problem invokes when I try to run some CLI process inside this server shell that should get input from the shell (user input) and return the output to the shell (print it on screen) , In this case chan.exec_command is returning me None (NoneType) instead of [stdin,stdout,stderr] tuple and raw_output variable (the output from the channel) is alsor returned as None and therefore nothing is printed eventually , moreover, I don't get any exception SshException thrown so that I understand that executing this command was successful.
This is very strange because when I do this interactively (connecting manually to the server) and running the commands that connecting to the shell everything prints O.K. on the terminal.
[ example : print(self.ssh.get_remote_output("echo -e 'show cable rpd' | /opt/confd/bin/confd_cli --noaaa "))]

I read exec_command user manual and didn't see anything that should cause such behaviour.

This is the log I get from the logger:

DEBUG:paramiko.transport:starting thread (client mode): 0x75a745c0
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.4.2
DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u6
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_7.4p1)
DEBUG:paramiko.transport:kex algos:['curve25519-sha256', '[email protected]', 'ecdh-sha2-nistp256', 'ecdh-sha2-nistp384', 'ecdh-sha2-nistp521', 'diffie-hellman-group-exchange-sha256', 'diffie-hellman-group16-sha512', 'diffie-hellman-group18-sha512', 'diffie-hellman-group14-sha256', 'diffie-hellman-group14-sha1'] server key:['ssh-rsa', 'rsa-sha2-512', 'rsa-sha2-256', 'ecdsa-sha2-nistp256', 'ssh-ed25519'] client encrypt:['[email protected]', 'aes128-ctr', 'aes192-ctr', 'aes256-ctr', '[email protected]', '[email protected]'] server encrypt:['[email protected]', 'aes128-ctr', 'aes192-ctr', 'aes256-ctr', '[email protected]', '[email protected]'] client mac:['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', 'hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha1'] server mac:['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', 'hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha1'] client compress:['none', '[email protected]'] server compress:['none', '[email protected]'] client lang:[''] server lang:[''] kex follows?False
DEBUG:paramiko.transport:Kex agreed: ecdh-sha2-nistp256
DEBUG:paramiko.transport:HostKey agreed: ssh-ed25519
DEBUG:paramiko.transport:Cipher agreed: aes128-ctr
DEBUG:paramiko.transport:MAC agreed: hmac-sha2-256
DEBUG:paramiko.transport:Compression agreed: none
DEBUG:paramiko.transport:kex engine KexNistp256 specified hash_algo <built-in function openssl_sha256>
DEBUG:paramiko.transport:Switch to new keys ...
DEBUG:paramiko.transport:Adding ssh-ed25519 host key for [10.40.2.142]:2022: b'c145a1e3b7fc4252387d5930a73cc2c9'
DEBUG:paramiko.transport:userauth is OK
INFO:paramiko.transport:Authentication (password) successful!
DEBUG:framework.ssh_client:SSH connection to 10.40.2.142:2022 is open
DEBUG:framework.ssh_client:This message should appear on the console: 
DEBUG:paramiko.transport:[chan 0] Max packet in: 32768 bytes
DEBUG:paramiko.transport:Received global request "[email protected]"
DEBUG:paramiko.transport:Rejecting "[email protected]" global request from server.
DEBUG:paramiko.transport:[chan 0] Max packet out: 32768 bytes
DEBUG:paramiko.transport:Secsh channel 0 opened.
DEBUG:framework.ssh_client:Executed SSH command: /opt/confd/bin/confd_cli --noaaa
DEBUG:framework.ssh_client:Attempt #1 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #2 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #3 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #4 to check data in the channel:                                                                                                                                                                                                            
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #5 to check data in the channel:                                                                                                                                                                                                            
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #6 to check data in the channel:                                                                                                                                                                                                            
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #7 to check data in the channel:                                                                                                                                                                                                            
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #8 to check data in the channel:                                                                                                                                                                                                            
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #9 to check data in the channel:                                                                                                                                                                                                            
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #10 to check data in the channel:                                                                                                                                                                                                           
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #11 to check data in the channel:                                                                                                                                                                                                           
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #12 to check data in the channel:                                                                                                                                                                                                           
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #13 to check data in the channel:                                                                                                                                                                                                           
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #14 to check data in the channel:                                                                                                                                                                                                           
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #15 to check data in the channel:                                                                                                                                                                                                           
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #16 to check data in the channel:                                                                                                                                                                                                           
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #17 to check data in the channel:                                                                                                                                                                                                           
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds                                                                                                                                                                                  
DEBUG:framework.ssh_client:Attempt #18 to check data in the channel:                                                                                                                                                                                                           
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #19 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #20 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #21 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #22 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #23 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #24 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #25 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #26 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #27 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #28 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #29 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #30 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #31 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #32 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #33 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #34 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #35 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #36 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #37 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #38 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #39 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #40 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #41 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #42 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #43 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #44 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #45 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #46 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #47 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #48 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #49 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #50 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #51 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #52 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #53 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #54 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #55 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #56 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #57 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #58 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #59 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #60 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #61 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #62 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #63 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #64 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #65 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #66 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #67 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #68 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #69 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #70 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #71 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #72 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #73 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #74 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #75 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #76 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #77 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #78 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #79 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #80 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #81 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #82 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #83 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #84 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #85 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #86 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #87 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #88 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #89 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #90 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #91 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #92 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #93 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #94 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #95 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #96 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #97 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #98 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #99 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Attempt #100 to check data in the channel:
DEBUG:framework.ssh_client:Data is NOT ready yet to be read from channel. Waiting 0.1 seconds
DEBUG:framework.ssh_client:Data is not ready to be read from channel. All 100 attempts are exhausted
DEBUG:framework.ssh_client:ERROR: Unable to get remote output
DEBUG:framework.ssh_client:Raw output:
None
DEBUG:paramiko.transport:[chan 0] EOF sent (0)
1
I've edited the question with my log file output - ms_stud

1 Answers

0
votes

There are two different exec_command functions in paramiko. The one you execute is not supposed to return any value. Use paramiko.SSHClient.exec_command which returns (stdin, stdout, stderr).

Details below:

http://docs.paramiko.org/en/2.4/api/channel.html?highlight=exec_command http://docs.paramiko.org/en/2.4/api/client.html?highlight=exec_command

Docstrings:

>>> help(paramiko.channel.Channel.exec_command)
Help on method exec_command in module paramiko.channel:

exec_command(self, *args, **kwds) unbound paramiko.channel.Channel method
    Execute a command on the server.  If the server allows it, the channel
    will then be directly connected to the stdin, stdout, and stderr of
    the command being executed.

    When the command finishes executing, the channel will be closed and
    can't be reused.  You must open a new channel if you wish to execute
    another command.

    :param str command: a shell command to execute.

    :raises:
        `.SSHException` -- if the request was rejected or the channel was
        closed



>>> help(paramiko.SSHClient.exec_command)
Help on function exec_command in module paramiko.client:

exec_command(self, command, bufsize=-1, timeout=None, get_pty=False, environment=None)
    Execute a command on the SSH server.  A new `.Channel` is opened and
    the requested command is executed.  The command's input and output
    streams are returned as Python ``file``-like objects representing
    stdin, stdout, and stderr.

    :param str command: the command to execute
    :param int bufsize:
        interpreted the same way as by the built-in ``file()`` function in
        Python
    :param int timeout:
        set command's channel timeout. See `.Channel.settimeout`
    :param dict environment:
        a dict of shell environment variables, to be merged into the
        default environment that the remote command executes within.

        .. warning::
            Servers may silently reject some environment variables; see the
            warning in `.Channel.set_environment_variable` for details.

    :return:
        the stdin, stdout, and stderr of the executing command, as a
        3-tuple

    :raises: `.SSHException` -- if the server fails to execute the command