Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to: Simulating keystroke inputs in shell to an app running in an embedded target

I am writing an automation script that runs on an embedded linux target.

A part of the script involves running an app on the target and obtaining some data from the stdout. Stdout here is the ssh terminal connection I have to the target.

However, this data is available on the stdout only if certain keys are pressed and the key press has to be done on the keyboard connected to the embedded target and not on the host system from which I have ssh'd into the target. Is there any way to simulate this?

Edit: Elaborating on what I need -

I have an OpenGL app that I run on the embedded linux (works like regular linux) target. This displays some graphics on the embedded system's display device. Pressing f on the keyboard connected to the target outputs the fps data onto the ssh terminal from which I control the target.

Since I am automating the process of running this OpenGL app and obtaining the fps scores, I can't expect a keyboard to be connected to the target let alone expect a user to input a keystroke on the embedded target keyboard. How do I go about this?

Edit 2: Expect doesn't work since expect can issue strokes only to the ssh terminal. The keystroke I need to send to the app has to come from the keyboard connected to the target (this is the part that needs simulation without actually having a keyboard connected to it).

Thanks.

like image 304
fzkl Avatar asked Feb 25 '23 12:02

fzkl


1 Answers

This is exactly the domain of Expect , which stackoverflow incidentally recognizes with its own tag.

The quickest way to achieve the OpenGL automation you're after, while learning as little of Expect as necessary, is likely by way of autoexpect.

like image 78
Cameron Laird Avatar answered Mar 05 '23 15:03

Cameron Laird