There are as many threads running as there are machines and commands
Only if you run the different commands for each machine from different threads. That's the wrong way to do it.
If you look at the code snippets I posted, one thread connect to one machine, opens one file, and runs all the commands for that machine, sequentially. That way, there is no possibility for ordering problems or file conflicts.
Maybe I am missing something?
Please read my last post slowly and thoroughly. Making multiple connections to each machine from different threads to run single commands is both inefficient and the source of your problems.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.