CommandPort is meant for sending commands rather than retrieving output, there's still a way to do it: the trick is you need to send each command and receive output separately: https://forums.cgsociety.org/t/telnet-or-socket-no-result-back-from-maya/1730817/2
But the smart way to do is using maya.api.OpenMaya
MCommandMessage
message callback to stream output that maya received; So basically, a server (editor) client (maya) to send command, and another client (editor) server to stream output. This is how plugin's like MayaCharm (for PyCharm) and MayaSublime (for Sublime) work, and this is what I ended up choosing after some research. See detail examples:https://www.xingyulei.com/post/maya-commandport/https://www.xingyulei.com/post/maya-streaming/