My question concerns the type (3) "COPY CON": I need to interpretate the command which the user types behind the prompt. My first idea is to search for "<space>CON<space>" ?
You'll need to search for COPY followed by CON because there are other contexts in which CON is used (redirection for example). Doing that in a robust way is going to require dealing with an arbitrary number of spaces and text (filenames for example) between the COPY and the CON so I would suggest using a regular expression.
However the command shell expects line oriented input, so if you send a line containing COPY CON then the shell will then read input on stdin line by line and echo that input on stdout, up until it receives an EOF, which you're writing and reading stdin and stdout already anyway.
If what you wish to do is send an arbitrary block of text, possibly containing newlines, as an argument to an arbitrary command then I would suggest using a separate command to do that. Something along the lines of a send marked block command.
If you are doing all this command line processing before sending a line to the command processor you're not really creating a command line front end, you are implementing half a command processor and duplicating functions that the shell already implements. If that's what you want to do then you should look at examples of scanners and parsers. In the C world there are tools for creating these, Lexx and Yacc (Flex and Bison) Free Pascal comes with Plex and Pyacc. Using specialised tools for this is advisable because, while creating a scanner and parser isn't complicated it's not trivial , and creating an efficient scanner and parser is definitely not an exercise for the faint of heart.