Remote Input Simulation for CLI Applications (Beyond Visualization) #4225
Replies: 2 comments 3 replies
-
Hi there. Great question. I haven't done that before, but I did some research and maybe one good way to simulate remote input (like typing and pressing Enter) into a CLI app is by using a pseudo-terminal (PTY). It acts like a real terminal, so your app thinks someone is typing: Example in Python:
You can also try:
|
Beta Was this translation helpful? Give feedback.
-
Why not just |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm exploring ways to introduce remote input into a CLI application, specifically aiming to simulate the behavior of typing text into the CLI and pressing Enter, but from a remote source. The goal is to trigger actions in the CLI application (for example, to interact with Gemini models) just as if the input were entered manually.
Currently, the application processes input received via stdin when a user types something and presses Enter. I'm looking for methods to replicate this behavior remotely, without relying on visual screen sharing or similar visualization-based techniques.
In essence, I need a way to programmatically "inject" text and Enter key presses into the CLI application's input stream from a remote source.
Are there any recommended approaches or existing libraries/tools that would facilitate this type of remote input simulation? I'm open to various methods, including (but not limited to):
Using pipes or other inter-process communication (IPC) mechanisms.
Employing a virtual terminal (pty) and writing to its input.
Leveraging specific language/platform features for input redirection or simulation.
Any suggestions or insights would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions