Package: python-paramiko
Version: 1.7.4-0.1
Severity: normal
First of all, thanks for paramiko, to both you and the upstream.
def execCmdSSH(self, command):
stdin, stdout, stderr = self.__conn.exec_command(command)
log.msg(stdout.read())
This is my example code, where I just pass in a command to exec_command() and
read out the output to my logger, log.
| exec_command(self, command)
| 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 command: a shell command to execute.
| @type command: str
|
| @raise SSHException: if the request was rejected or the channel was
| closed
As far as I understood it, it just is giving me the descriptors.
So I just went ahead and did a full read().
read() says:
read(...)
read([size]) -> read at most size bytes, returned as a string.
If the size argument is negative or omitted, read until EOF is reached.
Notice that when in non-blocking mode, less data than what was requested
may be returned, even if no size parameter was given.
As it says, keep reading until EOF.
In my case, in the above example, it reads and then gets a 'None'.
My logger, log, only accepts strings. So it fails when it receives a 'None'.
Am I doing something wrong here in the way I'm reading the output from
exec_command() ??
r...@champaran:~/devel/lunadm (master)$ ./lunadm show -t 10.72.201.72
Hostname: 10.72.201.72
Username [rrs]: root
Password for [email protected]:
/vol/vol1/lnx-ibm-sanboot 5g (5368709120) (r/w, online, mapped)
Traceback (most recent call last):
File "./lunadm", line 16, in <module>
main()
File "/home/rrs/devel/lunadm/lunadm_core.py", line 474, in main
log.msg(connection.execCmd("lun " + cmd) )
File "/home/rrs/devel/lunadm/lunadm_core.py", line 137, in msg
sys.stdout.write(msg)
TypeError: argument 1 must be string or read-only character buffer, not None
Is this 'None' intentional ?
How do I read from the tuple that exec_command() gives ?
Regards,
Ritesh
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (101, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.31-1-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages python-paramiko depends on:
ii python 2.5.4-2 An interactive high-level object-o
ii python-crypto 2.0.1+dfsg1-4 cryptographic algorithms and proto
ii python-support 1.0.4 automated rebuilding support for P
python-paramiko recommends no packages.
python-paramiko suggests no packages.
-- no debconf information
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]