How to execute a python script on a remote machine after accessing via PuTTY (SSH)?

Viewed 94

I want to execute a python script on a remote raspberry pi from a windows 7 machine. To archive this I want to write a python script on the windows machine. Unfortunately I cannot use the "ssh" command since win 7 doesn't support it. Installing new software is not really possible since the machine is very restrictive. So I am stuck with PuTTY.

I can access the Rasp Pi with no problem using:

import os

os.system('cmd /c "putty.exe -ssh pi@xxx.xxx.xxx.xxx -pw SomePassword"')

after that the Raspberry Pi shell opens up. Triggering the script manually is again not the problem:

python Desktop/script.py

But how do I run the command after accessing the shell? How do I run a command in the "new" shell. If I keep using os.system('cmd') I only execute stuff in the Windows command prompt.

I think I should use python subprocess but I cannot figure out how to link the command for opening PuTTY and then running the script on the remote machine. Any help would be greatly appreciated.

Thanks in advance

0 Answers
Related