Please follow up on your comment regarding $?. Please check the file for this script in your installation. I did not change this.
After many days, the detection script has not run. Is there a way to trigger?
The PNP scripts will run after a router reload on each MD that has an un-allocated (unused) serial port.
First thing I see now that I have some time is that you seem to have added the "Resp=$?" portion to the echo command, it will not give you the output you are expecting, but the output of the IF statement result. The "$?" returns the exit code of the last command executed.
Second thing is "PWSTANDBY\rZMOFF\rZ2OFF\rPWON\rZMON\rZ2ON\r", which shows in your testing output is not the same as what the script you posted is sending, you must be testing with a different script. This script should be short and only enough to confirm that it responds to commands, adding in zone power off/on is adding a lot of extra commands that are not necessary for detecting the receiver.
You also indicate that the script works 'sometimes' but not others. This is usually a result of serial based devices that decide not to respond, they can get 'confused' usually based on some bad codes or text sent to its' port. Some serial devices are really susceptible to this. If the script works 'sometimes' I would suggest that the exact sequence of commands could be altered or more pause/delay after each command. The receiver needs to have time to respond prior to another command being sent.
The Denon detection script has worked for me here on my Denon 3311CI. That was when I first purchased the amp, since then it does not need to be re-detected. Honestly my best recommendation is to add the device manually if the detection script isn't doing its' thing properly. After that it's never required again.