【发布时间】:2015-04-30 12:13:58
【问题描述】:
t 我有以下代码,它使用 ssh 和 sftp ssh 到网络上的构建服务器并运行本机 mkdir 和 chdir 命令,如何使用我在构建服务器上本地安装的一些可执行文件运行任何自定义命令?
import paramiko
ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.connect('buildservername', username='yadomi', password='password')
sftp = ssh.open_sftp()
sftp.chdir('/local/mnt/workspace/newdir')
commandstring = 'repo init -u git://git.company.com/platform/manifest -b branchname --repo-url=git://git.company.com/tools/repo.git --repo-branch=caf/caf-stable'
si,so,se = ssh.exec_command(commandstring)
readList = so.readlines()
print readList
print se
错误:-
<paramiko.ChannelFile from <paramiko.Channel 1 (closed) -> <paramiko.Transport at 0x2730310L (cipher aes128-ctr, 128 bits) (active; 1 open channel(s))>>>
【问题讨论】:
-
只要
PATHenv 变量是正确的,你只需要si,so,se = ssh.exec_command(commandstring)readList = so.readlines()