When i ping servers with os.system in python i get multiple response codes.
Command used - os.system("ping -q -c 30 -s SERVERANME")
When one makes a request to a URI, it returns a response. This Response object in terms of python is returned by requests.method(), method being – get, post, put, etc. Response is a powerful object with lots of functions and attributes that assist in normalizing data or creating ideal portions of code.
Python - Request Status Codes. After receiving and interpreting a request message, a server responds with an HTTP response message. The response message has a Status-Code. It is a 3-digit integer where first digit of the Status-Code defines the class of response and the last two digits do not have any categorization role.
This response code is used when the Range header is sent from the client to request only part of a resource. Conveys information about multiple resources, for situations where multiple status codes might be appropriate.
The response message has a Status-Code. It is a 3-digit integer where first digit of the Status-Code defines the class of response and the last two digits do not have any categorization role. There are 5 values for the first digit: It means the request was received and the process is continuing.
Per the docs:
On Unix, the return value is the exit status of the process encoded in the format specified for
wait()
. Note that POSIX does not specify the meaning of the return value of the Csystem()
function, so the return value of the Python function is system-dependent.
And the wait
docs say:
Wait for completion of a child process, and return a tuple containing its pid and exit status indication: a 16-bit number, whose low byte is the signal number that killed the process, and whose high byte is the exit status (if the signal number is zero); the high bit of the low byte is set if a core file was produced.
So 0, 256 and 512 correspond to ping
exiting normally (not killed by signal) with exit statuses of 0 == 0 << 8
(0
traditionally means "success"), 256 == 1 << 8
(1
typically means "normal" failure) and 512 == 2 << 8
(not consistent, but 2
is frequently used to indicate an argument parsing failure). In this case, you passed -s
without providing the mandatory value (packetsize
) that switch requires, so an exit status of 2
makes sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With