How to run OS commands using python in DS
like
import subprocess
def ping(host):
result = subprocess.run(
["ping", "-n", "4", host], # -n 4 = 4 packets (Windows)
capture_output=True,
text=True
)
return result.stdout
print(ping("8.8.8.8"))
or
import os
result = os.popen("ping -n 1
google.com").read()
print(result)