What if the called application runs for say 2.5 hours? $exec couldnt simply return the data from the pipe becasue it doesnt know when the application is finished writing to it.

Maybe a buffer allowance on mIRC's end? Not sure if you are farmiliar with php, but you can execute a command, and have its return outputted to the webpage. Changing the buffer can also make it either wait for the application to finish before displaying it. Or, for something like the displayal of a tracert, have the buffer at 2bytes so the user can view it happening, and not think the webpage hung up.