I am using python 3.2 currently and I wanted to do write a code that generates 3 instances of command prompt in windows. I then need to access a different server in each of these command prompts using Plink (putty) and run a time consuming program in each of these command prompts in parallel. While I was able to create three instances of command prompts, I was not able to send commands to these prompts. Is there any method to do so? Should I use multiprocessing/ multithreading for this purpose?
I wrote the following code for creating the command prompts. Is there any way to pass commands to each of these prompts?
def Plink():
name = multiprocessing.current_process().name
proc = subprocess.Popen("C:\\Windows\\System32\\cmd.exe")
if __name__ == '__main__':
Plink_1 = multiprocessing.Process(name='Plink 1', target=Plink)
Plink_2 = multiprocessing.Process(name='Plink 2', target=Plink)
Plink_3 = multiprocessing.Process(name='Plink 3', target=Plink)
Plink_1.start()
Plink_2.start()
Plink_3.start()
Um, what?
What you want to do isn’t what is generally referred to as “multi-processing”…
Using Paramiko
Here’s how you can use paramiko to connect to a remote SSH server and run a command.
You can also have it use public key auth, check the docs.