I want to remotely execute tracert in a Windows machine with PHP exec(). I have:
<?php
echo exec("C:\\Windows\\System32\\TRACERT.exe");
echo "<br/>Success!";
?>
This does not give me errors and it prints "Success!." But how do I pass an argument (such as an IP address to tracert.exe and print the result in a variable or array? I do not know the syntax to pass an argument that looks like: tracert , etc.
I prefer passthru() as the traceroute output can be watched in browser on the fly, not having to wait until completed.
$IP=$_REQUEST['IP'];
set_time_limit(120);
echo "<h1>Traceroute $IP</h1><pre>";
passthru("tracert.exe -h 8 $IP");