I'm using the exec function in PHP to run the Linux mtr command (for traceroutes), but when I run it, I get a status code of 1 when I pass my domain into the command, but if I pass the --help flag or --version flag then I get a result instantly and it shows in my JSON.
How can I make the exec function essentially wait until it's returned the result of the traceroute since I fear that's the issue here?
If I run mtr from the command line, all the failing ones above will work as expected, granted, that a traceroute could take up-to 30 seconds to run, surely the exec waits though?
I'm using the
exec
function in PHP to run the Linuxmtr
command (for traceroutes), but when I run it, I get a status code of 1 when I pass my domain into the command, but if I pass the--help
flag or--version
flag then I get a result instantly and it shows in my JSON.How can I make the
exec
function essentially wait until it's returned the result of the traceroute since I fear that's the issue here?Works: gives me a code of 0 and a result in out
Works: gives me a code of 0 and a result in out
Failing: gives me a code of 1 and no result
Failing: gives me a code of 1 and no result
If I run
mtr
from the command line, all the failing ones above will work as expected, granted, that a traceroute could take up-to 30 seconds to run, surely theexec
waits though?How can I resolve this?