标签云

微信群

扫码加入我们

WeChat QR Code

I execute the ping command in python by opening a cmd window with the ping command using python's subprocess module.For example:import subprocessp = subprocess.Popen('ping 127.0.0.1')Afterwards I check if the output contains "Reply from 'ip':", to see if the ping was successful.This works in all cases where the cmd is in english.What can I do to check if a ping was successful on any cmd language?


related: Ping a site in Python?

2019年04月19日34分31秒

This would work with a simple ping I agree, but what If I have a loop in the batch that pings and returns many results?

2019年04月19日34分31秒

yuval You want to do the loop in python or in bash?

2019年04月19日34分31秒

in bash, "cmd /C for /l %i in (1, 1, 254) do ping -w 2000 -n 1 195.218.195.%i"

2019年04月19日34分31秒