你这个脚本有些语法问题,不过总的设计思路是没有问题的。 我已经用你的脚本执行了,输入如下。我觉得可以讲hosts.txt文件拆分成5个文件,每个文件含8条ip,按顺序执行,这样可以控制每次只处理8个ip,也就达到并发8台机子的要求。
python multhred.py "echo 'hello world'"
Please input password:
current has 1 threads
current has 3 threads
current has 4 threads
current has 6 threads
current has 8 threads
current has 11 threads
current has 12 threads
current has 14 threads
hello world
172.***.***.*** OK
hello world
172.***.***.*** OK
hello world
172.***.***.*** OK
hello world
172.***.***.*** OK
hello world
172.***.***.*** OK
hello world
172.***.***.*** OK
hello world
172.***.***.*** OK
hello world
172.***.***.*** OK