All,
I am stumped at the moment....
I am trying to run an os.system command and in turn write the value to a string so I can check the outcome.
Basically I need to ping a machine on the server, write the results of the ping to a string and then search the string and extract the result.
So far I have this (I have not got onto the searching string code yet as I keep getting 0!!):
I just keep getting '0' as the output??? Any ideas....Code:import os # Ping Server to make sure it is available os.system('cls') print("Pinging Server to ensure it is online") print("") Server_Up = os.system('ping 192.168.0.1') print("") print(Server_Up) print("")
What I expect to see whent I print the string is:
Pinging Server [192.168.0.1] with 32 bytes of data:
Reply from 192.168.0.1: bytes=32 time<1ms TTL=64
Reply from 192.168.0.1: bytes=32 time<1ms TTL=64
Reply from 192.168.0.1: bytes=32 time<1ms TTL=64
Reply from 192.168.0.1: bytes=32 time<1ms TTL=64
Ping statistics for 192.168.0.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
Social Networking Bookmarks