ローカルPythonリモートサーバPythonスクリプトの実行
785 ワード
:
pc (windows Linux) Python , ?
: xshell
, ?
?
# -*-coding:utf-8
# author:lihaizhen
# date:
# description:
import paramiko,time
# SSH
ssh = paramiko.SSHClient()
# know_hosts
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
#
ssh.connect(hostname='xx.xx.xx.xx', port=22, username='', password='')
#
stdin, stdout, stderr = ssh.exec_command('python /xx/xx/xx.py')
#
result = stdout.read().decode('utf8')
print(result) #
#
ssh.close()
必要に応じてwindowsタイミングタスクにパッケージ化してタイミング実行することもできます
(なぜこんなことを?xshellは不便なのか、もちろんそうではありません.これは本当に業務部門(非IT人事)の需要に対して作ったものです)