Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python web框架将消息从远程ssh服务器显示到我的html页面_Python_Html_Flask_Server_Paramiko - Fatal编程技术网

使用Python web框架将消息从远程ssh服务器显示到我的html页面

使用Python web框架将消息从远程ssh服务器显示到我的html页面,python,html,flask,server,paramiko,Python,Html,Flask,Server,Paramiko,我使用Python flask和paramiko从html表单在远程ssh服务器上执行命令 它应该能够将消息显示回我的html文件: (来自ssh服务器中执行的文件的结果) 欢迎任何想法或网站链接 谢谢。您可以在函数中使用类似的内容。调用函数后,将“输出”返回到html import sys, paramiko if len(sys.argv) < 4: print "args missing" sys.exit(1) hostname = sys.argv[1] p

我使用Python flask和paramiko从html表单在远程ssh服务器上执行命令

它应该能够将消息显示回我的html文件:

(来自ssh服务器中执行的文件的结果)

欢迎任何想法或网站链接


谢谢。

您可以在函数中使用类似的内容。调用函数后,将“输出”返回到html

import sys, paramiko


if len(sys.argv) < 4:
    print "args missing"
    sys.exit(1)

hostname = sys.argv[1]
password = sys.argv[2]
command = sys.argv[3]

username = "admin"
port = 22

try:
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.WarningPolicy())

    client.connect(hostname, port=port, username=username, password=password)

    stdin, stdout, stderr = client.exec_command(command)
    output = stdout.read(),

finally:
    client.close()
导入系统,paramiko 如果len(sys.argv)<4: 打印“缺少参数” 系统出口(1) 主机名=sys.argv[1] 密码=sys.argv[2] command=sys.argv[3] username=“admin” 端口=22 尝试: client=paramiko.SSHClient() client.load\u system\u host\u key() client.set_缺少_主机_密钥_策略(paramiko.WarningPolicy()) client.connect(主机名,端口=端口,用户名=用户名,密码=密码) stdin,stdout,stderr=client.exec_命令(command) output=stdout.read(), 最后: client.close()
这个问题您已经问过两次了:+