Oct-14-2016, 03:14 PM
(Oct-14-2016, 03:08 AM)Skaperen Wrote:Yes subprocess is top secret stuff :silenced:(Oct-14-2016, 02:18 AM)wavic Wrote: I don't like to use subprocess.is there some knowledge base around this that i do not have?
import subprocess website = "google.com" ping = subprocess.Popen(["ping", website], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, error = ping.communicate() print(out.decode('utf-8'))
Output:Pinging google.com [193.212.4.59] with 32 bytes of data:
Reply from 193.212.4.59: bytes=32 time=14ms TTL=60
Reply from 193.212.4.59: bytes=32 time=13ms TTL=60
Reply from 193.212.4.59: bytes=32 time=12ms TTL=60
Reply from 193.212.4.59: bytes=32 time=11ms TTL=60
Ping statistics for 193.212.4.59:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 11ms, Maximum = 14ms, Average = 12ms