Mailinglist Archive: opensuse (2348 mails)

< Previous Next >
[opensuse] Quick bash question - testing for the presence of keyboard input without pausing a loop?
  • From: "David C. Rankin" <drankinatty@xxxxxxxxxxxxxxxxxx>
  • Date: Sat, 05 Apr 2008 01:45:42 -0500
  • Message-id: <47F72016.2070406@xxxxxxxxxxxxxxxxxx>

I'm stuck. I would like to write a bash routine that tests for the presence of a user keypress ('q' or 'e') to exit a loop from within the loop without stopping the loop to wait like with read. Basically just execute the loop until the user presses a key, any key, to stop it. I can't figure out how do that will a keypress.

As a work around, I'm using a basic file ".runmcelog" file for that purpose:

while [ -f "/home/david/.runmcelog" ]; do
sudo /usr/sbin/mcelog --k8

Which requires that I delete and touch .runmcelog to stop and reset the script, but there has to be a better way. What says the braintrust on this issue?

David C. Rankin, J.D., P.E.
Rankin Law Firm, PLLC
510 Ochiltree Street
Nacogdoches, Texas 75961
Telephone: (936) 715-9333
Facsimile: (936) 715-9339
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
This Thread