[paramiko] (no subject)
Kevin Horn
kevin at techadept.com
Fri Mar 9 08:24:26 PST 2007
If I'm reading the API docs correctly, channel.exec_command does not
appear to have a return value, so (IIRC) it will always evaluate to
"None" in a boolean expression.
Thus your test will always evaluate to true, whether the command runs or
not.
Someone a little more familiar with paramiko want to either back me up
or correct me on this?
Kevin Horn
Dony Pierre wrote:
> Hi all,
>
> I'm new python and in paramiko, so can you please help me with this
> problem =
>
> Here is my code (with cmd = "ls")
> <<<<
> paramiko.util.log_to_file('ssh-cmd.log')
> client = paramiko.Transport((hostname,hostport))
> client.connect(username=username,password=password)
> channel=client.open_session()
>
> if not channel.exec_command(cmd):
> raise 'Error:Failed to run command', cmd
>
> stdout = channel.makefile('rb')
>
> for line in stdout:
> print line.strip('\n')
> <<<<<
> gives the following error :
>
> Traceback (most recent call last):
> File "check_brocade1.py", line 32, in ?
> raise 'Error:Failed to run command', cmd
> Error:Failed to run command: ls
>
> Output ssh-cmd.log is :
>
> DEB [20070123-08:26:28.698] thr=1 paramiko.transport: starting thread
> (client mode): 0xB7C582ECL
> INF [20070123-08:26:28.706] thr=1 paramiko.transport: Connected
> (version 2.0, client OpenSSH_3.9p1)
> DEB [20070123-08:26:28.712] thr=1 paramiko.transport: kex
> algos:['diffie-hellman-group-exchange-sha1',
> 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server
> key:['ssh-rsa', 'ssh-dss'] client encrypt:['aes128-cbc', '3des-cbc',
> 'blowfish-cbc', 'cast128-cbc', 'arcfour', 'aes192-cbc', 'aes256-cbc',
> 'rijndael-cbc at lysator.liu.se', 'aes128-ctr', 'aes192-ctr', 'aes256-ctr']
> server encrypt:['aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc',
> 'arcfour', 'aes192-cbc', 'aes256-cbc', 'rijndael-cbc at lysator.liu.se',
> 'aes128-ctr', 'aes192-ctr', 'aes256-ctr'] client mac:['hmac-md5',
> 'hmac-sha1', 'hmac-ripemd160', 'hmac-ripemd160 at openssh.com',
> 'hmac-sha1-96', 'hmac-md5-96'] server mac:['hmac-md5', 'hmac-sha1',
> 'hmac-ripemd160', 'hmac-ripemd160 at openssh.com', 'hmac-sha1-96',
> 'hmac-md5-96'] client compress:['none', 'zlib'] server compress:['none',
> 'zlib'] client lang:[''] server lang:[''] kex follows?False
> DEB [20070123-08:26:28.712] thr=1 paramiko.transport: Ciphers agreed:
> local=aes128-cbc, remote=aes128-cbc
> DEB [20070123-08:26:28.713] thr=1 paramiko.transport: using kex
> diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local
> aes128-cbc, remote aes128-cbc; mac: local hmac-sha1, remote hmac-sha1;
> compression: local none, remote none
> DEB [20070123-08:26:28.930] thr=1 paramiko.transport: Switch to new
> keys ...
> DEB [20070123-08:26:28.932] thr=2 paramiko.transport: Attempting
> password auth...
> DEB [20070123-08:26:28.956] thr=1 paramiko.transport: userauth is OK
> INF [20070123-08:26:28.965] thr=1 paramiko.transport: Authentication
> (password) successful!
> DEB [20070123-08:26:28.998] thr=2 paramiko.transport.1: Max packet in:
> 34816 bytes
> DEB [20070123-08:26:29.004] thr=1 paramiko.transport.1: Max packet
> out: 32768 bytes
> INF [20070123-08:26:29.004] thr=1 paramiko.transport: Secsh channel 1
> opened.
> DEB [20070123-08:26:29.016] thr=1 paramiko.transport.1: Sesch channel
> 1 request ok
>
>
> Thanks for your help.
> Regards.
> Pierre.
>
>
>
>
> -----------------------------------------
> Visit our website! http://www.nbb.be
>
> "DISCLAIMER: The content of this e-mail message should not be
> construed as binding on the part of the National Bank of Belgium
> (NBB) unless otherwise and previously stated. The opinions
> expressed in this message are solely those of the author and do not
> necessarily reflect NBB viewpoints, particularly when the content
> of this message, or part thereof, is private by nature or does not
> fall within the professional scope of its author."
>
>
> _______________________________________________
> paramiko mailing list
> paramiko at lag.net
> http://mail.lag.net/mailman/listinfo/paramiko
More information about the paramiko
mailing list