I
I
iOrange2010-09-21 17:59:31
Python
iOrange, 2010-09-21 17:59:31

Python + paramiko + shell script?

Good afternoon!
My next task is to create an SSH connection to the server, upload files via SFTP (specifically, sorts) and run the build script there.
I'm doing this in Python using paramiko. Everything is OK except for the actual launch of the script. I run it through exec_command and see only a couple of first messages and then the script stops (it's Pythonic, which means exec_command worked). Tell me - how to wait for the completion of the script and display all its messages?
Here are code snippets:

paramiko.util.log_to_file('ssh_session.log')
ssh = SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

try:
    ssh.connect(ssh_conf.server_address, ssh_conf.server_port, ssh_conf.login, None, my_pkey, 60)
except:
    print 'Error connect'
    sys.exit(1)

_sftp = ssh.open_sftp()
SyncFolders(_sftp, ssh_conf.source_folder, ssh_conf.dest_folder)

print ssh.exec_command('chmod +x' + ssh_conf.dest_folder + '/build.sh')[1].read()
# iOrange - performing build
print ssh.exec_command('sh ' + ssh_conf.dest_folder + '/build.sh')[1].read()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EXSlim, 2010-09-21
@EXSlim

Fabric not suitable?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question