Your message dated Tue, 24 Nov 2009 13:07:39 +0530
with message-id <[email protected]>
and subject line Re: [paramiko] Fwd: Bug#556946: python-paramiko: returns None
in exec_command
has caused the Debian Bug report #556946,
regarding python-paramiko: returns None in exec_command
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)
--
556946: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=556946
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
Hi James and all,
As you mentioned, I wrote a small test case and was not able to reproduce the
problem. That led me to check my code and realized that I was doing something
wrong at my end.
stdout.read() works perfect. Not a bug.
On Monday 23 Nov 2009 20:43:29 james bardin wrote:
> On Mon, Nov 23, 2009 at 12:26 AM, Ritesh Raj Sarraf <[email protected]>
wrote:
> > 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() ??
>
> That sounds correct.
> Can you make a small test case where this happens? Reading a channel
> shouldn't ever be able to return anything but a string.
>
> -jim
>
--
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
"Necessity is the mother of invention."
signature.asc
Description: This is a digitally signed message part.
--- End Message ---