I have a script in which I want to disable the "Enter" key press. Actually my script executes some process in background. So, till that background process is running, I don't want "Enter" key to be pressed by user. Is this can be achieved using trap command?
Um, I am missing something. The whole point of running in the background is so that the foreground can do something else. Or so you can run several processes at one time. If you do not want the user to touch the keyboard, consider running the background process in the foreground, maybe display something showing the progress of the code.
my problem is, I am going to set the cursor using 'tput cup' command after this background process completes. so, my problem is the cursor moves to the next line if enter key have been pressed during this period. I want to protect that thing only. otherwise my program run very smoothly.
You can turn off the enter key for a foreground process with
#!/bin/bash
stty igncr
... your code here
stty -igncr
This will prevent cursor movement caused by the enter key but does not work when the process is in background (but the user can't do anything anyway while your code is running so why not run in foreground?).