{"id":6464,"date":"2021-11-19T08:44:32","date_gmt":"2021-11-19T08:44:32","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=6464"},"modified":"2021-11-19T08:49:11","modified_gmt":"2021-11-19T08:49:11","slug":"shell-script-to-exit-the-program-whenever-a-key-is-pressed","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/unix\/shell-script-to-exit-the-program-whenever-a-key-is-pressed\/9106.html","title":{"rendered":"Shell Script To Exit The Program Whenever A Key Is Pressed"},"content":{"rendered":"<p>I&#8217;m running a few operations using shell scripting. I&#8217;m looking for a piece of code that will do the following.<\/p>\n<p>Whenever the key x is pressed, the script should be terminated, and whenever the key m is pressed, it should go back to the main menu. (There is a function to invoke the main menu, so whenever m is pressed, it should call that function).<\/p>\n<p>These keys x and m should work at all times, ie even if I&#8217;m halfway thru the execution, if i press the key x, the script should immediately be terminated. Is there any possible way to implement this?<\/p>\n<p>P.S. : It would be better if a key combination is used, Eg. ctrl+x for exit and ctrl+m for main menu<\/p>\n<p>Please help<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":12},"question-category":[64],"question_tags":[],"class_list":["post-6464","question","type-question","status-publish","hentry","question-category-unix"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/6464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=6464"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=6464"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=6464"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=6464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}