paramiko exec_command 返回 shell 脚本 exit 值

来源:互联网 发布:mac里的照片导入ipad 编辑:程序博客网 时间:2024/05/22 15:36
import paramiko  
  
hostname = 'ip'
port = 22  
username = 'root'  
key_file = '/root/.ssh/id_rsa'  
key = paramiko.RSAKey.from_private_key_file(key_file) 

s = paramiko.SSHClient()  
s.load_system_host_keys()  
s.connect(hostname,port,username,pkey=key)  
stdin,stdout,stderr = s.exec_command('/bin/bash /root/auto_run/publish81.sh') 
channel = stdout.channel
status = channel.recv_exit_status()
print status
0 0
原创粉丝点击