Re: [paramiko] remote command info

2010-01-27 Thread james bardin
On Tue, Jan 26, 2010 at 5:20 PM, stefano landucci marlonba...@gmail.com wrote:
 Hi,

 I'm a paramiko's newbie. I started with a simple ssh connection and command
 execution like below:

 import sys
 import paramiko

 client = paramiko.SSHClient()
 client.load_system_host_keys()
 ip = 'ip_server'
 client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

 client.connect(ip,port=22,  username='my_user',password='**')


 i, o, e = client.exec_command('ls -la')

 print o.read()

 client.close()

 I don't understand the steps to exec multiple commands, like the example
 below.
 Es: if I exec before  cd /etc command and after few time I want to exec a
 ls command. What I do?


The short answer is, you don't.
Run your commands separately with exec_command(), and remove their
dependencies on one another, and you will be much happier.

You can get an interactive shell with invoke_shell(), but then you
have to script being interactive - send command, wait for complete
response or timeout, parse response and/or return code, send another
command, etc. Some situations may really require this, but they are
few and far between.

-jim

___
paramiko mailing list
paramiko@lag.net
http://www.lag.net/cgi-bin/mailman/listinfo/paramiko


Re: [paramiko] remote command info

2010-01-27 Thread stefano landucci
2010/1/27 james bardin jbar...@bu.edu

 The short answer is, you don't.
 Run your commands separately with exec_command(), and remove their
 dependencies on one another, and you will be much happier.


Ok.

I find the example below:

i, o, e = client.exec_command('cd /etc')

i.write('ls\n')
i.flush()

I test it, but don't work.
Waht do you think about it?

You can get an interactive shell with invoke_shell(), but then you
 have to script being interactive


I use it, but i don't like.

Thank's jim.
___
paramiko mailing list
paramiko@lag.net
http://www.lag.net/cgi-bin/mailman/listinfo/paramiko

[paramiko] remote command info

2010-01-26 Thread stefano landucci
Hi,

I'm a paramiko's newbie. I started with a simple ssh connection and command
execution like below:

import sys
import paramiko

client = paramiko.SSHClient()
client.load_system_host_keys()
ip = 'ip_server'
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

client.connect(ip,port=22,  username='my_user',password='**')


i, o, e = client.exec_command('ls -la')

print o.read()

client.close()

I don't understand the steps to exec multiple commands, like the example
below.
Es: if I exec before  cd /etc command and after few time I want to exec a
ls command. What I do?

Sorry for my base English.

Regards.

B_and_s
___
paramiko mailing list
paramiko@lag.net
http://www.lag.net/cgi-bin/mailman/listinfo/paramiko