![]() Sh-4.3$ : and speaking of which, to do so you just. ![]() Sh-4.3$ : or if this shell exits with a non-zero exit status Sh-4.3$ : this example loop quits after ten iterations Sh-4.3$ : if you press a key you get an interactive shell Here is a test run - the numbers printed at the head of each line is the value of the shell variable $SECONDS: 273315: do your stuff here maybe That or dd doesn't time-out because you press a key - in which case an interactive shell is invoked. An alternative PowerShell PAUSE command, which behaves more. The 'any key' message is slightly misleading because not every key will work to continue: Ctrl, Shift, Win,Alt. ' This can be more convenient as it will work with the space bar and many other keys. Every two seconds dd times out on its attempted read of stdin - redirected from /dev/tty - and the while loop loops. In Windows CMD the PAUSE command displays the message 'Press any key to continue. That is a little example while loop that I mocked-up for you to try out. ![]() Combine those two and you can do without sleep entirely, I think, and just let the terminal's read timeout do the work for you: s=$(stty -g /dev/null stty "$s")" || (exec sh)ĭo echo "$SECONDS:" do your stuff here maybe With stty you can set a min number of bytes to qualify a terminal read and a time out in tenths of a second. That will run the script and the window will remain open for any further input. An alternative to this is to run the script using CMD /K: START CMD /k C:\demo\yourscript.cmd. Pause is often used at the end of a script to give the user time to read some output text. With dd you can reliably read a single byte from a file. Pressing any key will resume the operation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |