Python script for SSH through PuTTY

后端 未结 3 1104
隐瞒了意图╮
隐瞒了意图╮ 2021-01-07 10:46

I am able to give the following command in the command-line

C:\\>cd \"C:\\Program Files\\ExtraPuTTY\\Bin\"

C:\\P         


        
3条回答
  •  清歌不尽
    2021-01-07 11:13

    You have to pass the cwd as the cwd parameter of the Popen:

    Popen(['putty.exe -ssh'...], shell=True, stdout=f, stderr=f, cwd=cwd)
    

    And you should use Plink, not PuTTY, for automating the remote command execution. The Plink accepts the command on its command-line (PuTTY does not):

    Popen(['plink.exe -ssh root@172.20.0.102 ls'], shell=True, stdout=f, stderr=f, cwd=cwd)
    

提交回复
热议问题