paramiko exec_command 返回 shell 脚本 exit 值

import paramiko  
  
hostname = '121.40.100.198'  
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

你可能感兴趣的:(paramiko exec_command 返回 shell 脚本 exit 值)