I'm sorry, I've misunderstood your issue initially. IIUC, you would like to change the format of the mdh's output. I would like to suggest the following alternatives: Use read_memory instead of mdh -- it's output is a Tcl list of read items with no additional formatting (in hex): $ echo 'read_memory 0x80000000 16 1; exit' | netcat localhost 4444 0xa001 Write a custom Tcl function to output the memory in the format you like and load the script via -f when running OpenOCD. I'd be cautious about changing...
AFAIU, Telnet is not designed for RPC, but rather for an interactive session. Please consider using Tcl RPC server instead. https://openocd.org/doc-release/html/Tcl-Scripting-API.html#Tcl-RPC-server
Deprecated commands with spaces require quotes