>>1
If I understood correctly, you want a program that will act as the client of another, as if you were typing stuff into this other program? This can be simple to complex, depending on how's that other program. Is it a text-based program (runs in a terminal, or command prompt window) and you don't mind exiting it at the end of your program, or you need to let the user take over the commanded program afterwards? Do you need to read what the other program says, or you can send everything blindly?
Save for a very simple case where you could use the standard output, IPC is out of the question as it has to be supported by both processes, i.e. the commanded process would have to support it. At worst you'll have to call some operating-system dependent functions to simulate user input right into the target process' input buffer.
But where does NetHack write your characters? It's 95% likely that the simplest solution to generate characters would be to generate or edit a savegame, not to control another process while it's running.