def exec_command(<EOL>self,<EOL>command,<EOL>bufsize=-<NUM_LIT:1>,<EOL>timeout=None,<EOL>get_pty=False,<EOL>environment=None,<EOL>):
chan = self._transport.open_session(timeout=timeout)<EOL>if get_pty:<EOL><INDENT>chan.get_pty()<EOL><DEDENT>chan.settimeout(timeout)<EOL>if environment:<EOL><INDENT>chan.update_environment(environment)<EOL><DEDENT>chan.exec_command(command)<EOL>stdin = chan.makefile("<STR_LIT:wb>", bufsize)<EOL>stdout = chan.makefile("<STR_LIT:r>", bufsize)<EOL>stderr = chan.makefile_stderr("<STR_LIT:r>", bufsize)<EOL>return stdin, stdout, stderr<EOL>
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 bool get_pty:
    Request a pseudo-terminal from the server (default ``False``).
    See `.Channel.get_pty`
: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

.. versionchanged:: 1.10
    Added the ``get_pty`` kwarg.