'On Python, How to open multiple command windows simultaneously (in cascade)
I intend to monitor connectivity (by ping ) 3 devices into the net. So far I tried the follow scripts but in some, the commands run in a single windows import os import multiprocessing
def xxx():
while True:
os.system('cmd /c "ping 192.168.1.254 -t " ')
if __name__ == '__main__':
jobs = []
for i in range(3 ):
p = multiprocessing.Process(target=xxx)
jobs.append(p)
p.start()
# _______________________________________________________
import threading
import os
def xxx():
os.system('cmd /c "ping 192.168.1.254 -t " ')
def yyy():
os.system('cmd /c "ping 127.1.1.0 -t " ')
def main():
server_thread = threading.Thread(target=xxx)
client_thread = threading.Thread(target=yyy)
server_thread.start()
client_thread.start()
#__________________________________________________
import os
import multiprocessing
def xxx():
os.system( 'cmd /c "ping 192.168.1.254 -t " ')
def yyy():
os.system('cmd /c "ping 127.1.1.0 -t "')
if __name__ == '__main__':
jobs = []
p = multiprocessing.Process(target=xxx)
jobs.append(p)
p.start()
q = multiprocessing.Process(target=yyy)
jobs.append(q)
q.start()
Solution 1:[1]
Maybe just run another Python script where you put your ping method or other from your main script with
subprocess.call('python ping_script.py', shell=True)
But if you want to have some visual on your processes I would recommend you to use Jupyter notebooks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Devyl |