我使用以下命令ssh到Windows服务器,我正在尝试使用set命令。这就是我在本地使用的工作原理:
set ASPERA_SCP_PASS=myPassword
ascp /directory/Test4.mov myAccount@10.1.1.1:/TEST
这是我的python命令:
shell = spur.SshShell(hostname=10.0.0.1, username=Wusername, password=Wpassword, missing_host_key=spur.ssh.MissingHostKey.accept)
result = shell.run(["set", "ASPERA_SCP_PASS=myPassword])
result = shell.run(["ascp.exe", "/directory/Test4.mov", "myAccount@10.1.1.1:/TEST"])
运行上面的内容时,我通过ssh成功连接,但是我在set
命令上收到此错误:
spur.results.RunProcessError: return code: 127
output: b''
stderr output: b'sh: line 0: exec: set: not found\n'
答案 0 :(得分:1)
我发现这很好用:
environment = {}
environment["ASPERA_SCP_PASS"] = "password"
shell = spur.SshShell(hostname="10.1.1.1", username="username", password="passowrd", missing_host_key=spur.ssh.MissingHostKey.accept)
result = shell.run(["ascp.exe", directory, "Ausername@10.0.0.1:/"], stdout=sys.stdout, update_env=environment)