noumanyasin Posted April 12, 2017 Share Posted April 12, 2017 I want o write a script in php to ping an IP address. Scenario is that If ping fails, it should run a window service on the same system. ping must repeat 3-4 times every 30 second. Please help me in this problem. Thanks Quote Link to comment Share on other sites More sharing options...
requinix Posted April 12, 2017 Share Posted April 12, 2017 PHP doesn't have a way to create pings - unless you want to craft the packets yourself. Quick answer: make a script that runs Windows' ping with its usual 4 attempts, parses the output to see how many were returned, and uses sc sc start to start the service if necessary. Quote Link to comment Share on other sites More sharing options...
noumanyasin Posted April 13, 2017 Author Share Posted April 13, 2017 $ip = "www.google.com";exec("ping -n 3 $ip", $output, $status);echo"<pre>";print_r($output);echo"</pre>"; Quote Link to comment Share on other sites More sharing options...
noumanyasin Posted April 13, 2017 Author Share Posted April 13, 2017 How "sc start<service>" works with it. Quote Link to comment Share on other sites More sharing options...
requinix Posted April 14, 2017 Share Posted April 14, 2017 However you want? You found out how to execute a command. Do it again with sc. Quote Link to comment Share on other sites More sharing options...
NigelRel3 Posted April 14, 2017 Share Posted April 14, 2017 I want o write a script in php to ping an IP address. Scenario is that If ping fails, it should run a window service on the same system. ping must repeat 3-4 times every 30 second. Please help me in this problem. Thanks Interested in what your attempting to achieve? Are you trying to get some form of failover, if so there are some more tried and reliable methods out there. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.