It seems that
OS.execute has an optional
output parameter that can be used to get the output of the command. I have not managed to make it working though. You can see here how this is implemented "under the hood".
It also appears that there are not support for inter process communications (such as shared memory or pipes) between Godot and other processes in the OS. Even if there was support, I am not sure it would have been portable.
One way to overcome this is to use
StreamPeerTCP to send and receive commands to the other process.
Even though both processes are on the same machine, it is a valid approach. Use
localhost as the address to which send the packets.