Python to run OS Commands

33 views
Skip to first unread message

Syed Munawer Hassan

unread,
Jan 30, 2026, 1:24:08 PM (5 days ago) Jan 30
to DroidScript
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)
Reply all
Reply to author
Forward
0 new messages