Yes, it can. But it's unlikely that you will do it.
One general method would be through the use of the <a href="http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fapis%2Fvt1a.htm">Virtual Terminal APIs</a>. It shouldn't take much reading about those to see why they aren't intended for trivial tasks.
Another method could be to open a socket to the telnet server and process the socket data. You can read the screen data that comes across the socket and send back data bytes that stands for key strokes. Your program needs to recognize every type of screen that might come up, including error message screens and the messages, break message screens and all others. That's not especially easier than the Virtual Terminal APIs.
The question doesn't make total sense.
You can't enter key strokes unless there is something to put the key strokes in to. Clearly, there must be some type of display file active that is waiting for input. The active display file will be the target of the key stroke.
But a display file is going to be waiting for a key stroke only if some program is already performing I/O through the display file. If that program is running, then your program won't be running. That other program will have the device allocated. If your program isn't running, then it can't enter key strokes. If the display file is waiting for input, then the program behind it isn't running -- it's in a wait state.
There are possible ways around all of that, but it gets complicated fast.
Your question needs to be asked differently.
You need to describe the <i>business problem</i> that you are trying to solve. A solution might be available that avoids complexities of key strokes.
Last Wiki Answer Submitted: October 31, 2010 7:59 am by TomLiotta110,175 pts.
All Answer Wiki Contributors: TomLiotta110,175 pts.