使用 Python 远程执行时 Curl 未打印

Curl is nor printing while executing remotely using Python

下面的代码没有打印任何东西。请让我知道脚本有什么问题。

import paramiko

ip='ip'
port=22
username='userid'
password='passwd'

cmd="""curl https://www.facebook.com"""

try:
    ssh=paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(ip,port,username,password)
    stdin,stdout,stderr=ssh.exec_command(cmd)
    outlines=stdout.readlines()
    resp=''.join(outlines)
    print(resp)

except:
    print("failed on login.") 

cmd 包含 non-breaking space 而不是正常的 space。删除 curl 命令后看起来像 space 的内容,并将其替换为真正的 space 字符。