This would be pretty useful if we could run some process and get the stdout.
Example usage:
CONST_HOST_START = "Pinging "
CONST_HOST_END = " with 32 bytes of data:"
CONST_SUCCESS = "Reply from "
(output, error) = system.util.exec(["ping", "192.168.1.1", "-n 1"])
host = "???"
isonline = "???"
# find target ip
start = output.find(CONST_HOST_START) + len(CONST_HOST_START)
end = output.find(CONST_HOST_END)
host = output[start:end]
#find state
if output.find("Reply from ") == -1:
isonline = 0
else:
isonline = 1
print host, result