2015-06-28 75 views
0

我正在使用下面的命令ssh進入一個windows服務器,我試圖使用set命令。這是我使用本地哪些工作:python spur ssh - 使用set命令

set ASPERA_SCP_PASS=myPassword 
ascp /directory/Test4.mov [email protected]:/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", "[email protected]:/TEST"]) 

當運行我通過SSH成功​​連接上,但我對得到這個錯誤set命令:

spur.results.RunProcessError: return code: 127 
output: b'' 
stderr output: b'sh: line 0: exec: set: not found\n' 

回答

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, "[email protected]:/"], stdout=sys.stdout, update_env=environment)