houkouonchi
01-30-2010, 11:29 AM
Warning !! PHP noob!!
I wanted to make a script page/script for running ping, traceroute, etc... but instead of showing the complete output after the command is running I want it to show the current output it is getting while the command is running (useful in traceroutes which if they start timing out at the last hop can take quite a bit of time to complete!
I know you can do this using ob_ functions for example:
ob_start();
for($i=0; $i < 10; $i++)
{
echo $i, ' ';
ob_flush();
flush();
sleep(1);
}
Which will print 1-10 waiting one second each time. This works fine on my server but I am not sure how to implement this with shell_exec. Can anyone lend me some expertise?
I know a couple traceroute/ping scripts exist out there but most of the ones I have tried suck and don't even escape the input from the browser and thus is basically giving someone shell access to my server via the user that apache runs as so I was thinking of just writing my own simple code to do what I want.
I wanted to make a script page/script for running ping, traceroute, etc... but instead of showing the complete output after the command is running I want it to show the current output it is getting while the command is running (useful in traceroutes which if they start timing out at the last hop can take quite a bit of time to complete!
I know you can do this using ob_ functions for example:
ob_start();
for($i=0; $i < 10; $i++)
{
echo $i, ' ';
ob_flush();
flush();
sleep(1);
}
Which will print 1-10 waiting one second each time. This works fine on my server but I am not sure how to implement this with shell_exec. Can anyone lend me some expertise?
I know a couple traceroute/ping scripts exist out there but most of the ones I have tried suck and don't even escape the input from the browser and thus is basically giving someone shell access to my server via the user that apache runs as so I was thinking of just writing my own simple code to do what I want.
