Answer the question
In order to leave comments, you need to log in
There was a question in decrypting nix, could you help?
Guys, could you help with decoding the exec fragment inside the brackets, both the first and the second. My ultimate task is to ping a gray ip every 30 seconds and display information about its status. If there are options about the implementation, I will be very grateful.
public function ping($phone_ip){
if ($this->myOS()){
if (!exec("ping -n 1 -w 1 ".$phone_ip." 2>NUL > NUL && (echo 0) || (echo 1)"))
return true;
} else {
if (!exec("ping -q -c1 ".$phone_ip." >/dev/null 2>&1 ; echo $?"))
return true;
}
return false;
}
Answer the question
In order to leave comments, you need to log in
exec("ping -n 1 -w 1 ".$phone_ip." 2>NUL > NUL && (echo 0) || (echo 1)")
phone_ip
, wait one second for a response, return 0 if a response is received, otherwise 1.ping
.
the first option for Windows, the second for Unix, the
keys say that you need to ping once and as quietly as possible, throw out all the output, except for stderr, if it exists, then print 0 otherwise 1.
Something like this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question