Injecting a keypress into a tool started by a bash script

1

I'm writing a bash script to gather some informations about disks and then start the 'nmon' tool to monitor only those specific disks.

I start the nmon tool out of the bash script (with -g). To get the correct view within the tool one need to press the g key on the keyboard.

Is there any way to get that keypress automatically triggered out of the bash script?

Thanks a lot!

user293584

Posted 2014-01-27T08:24:33.960

Reputation: 11

Answers

0

Try this:

echo -n "g" | nmon

For more infomation: https://stackoverflow.com/questions/6264596/simulating-enter-keypress-in-bash-script

Or use expect (man expect comes with examples).

Jared Allard

Posted 2014-01-27T08:24:33.960

Reputation: 389