View Single Post

   
  #5 (permalink)  
Old 01-04-2008, 10:51 PM
Nicholas Dronen
 
Posts: n/a
Default Re: How to trap any keyboard signal in a sript?

Bob Bale <balebob@hotmail.com> wrote:
BB> Thank you very much for all your suggestion.

BB> I am thinking if I replace a cat command with a more command. Then I
BB> can get out of the message any time I want. However, the system can
BB> sit there for an hour if I am not press any key. Is there a way to do
BB> like pausing for 60s if no key is hit then go to the next command,
BB> instead of waiting for user to hit any key? It sounds simple, but I
BB> do not know if it can be done or not.

#!/bin/ksh
trap : 2

clear; ( less /etc/hosts & ); pid=$!

sleep 60
if ps -p $pid >/dev/null 2>&1
then
kill $pid
fi

stty sane
echo "\n$0"

Again, the user should be told that they have to press CTRL-C
to continue, if they want to preempt the 60-second sleep.

Regards,

Nicholas

--
http://www.faqs.org/rfcs/rfc1855.html
3.1.1 General Guidelines for mailing lists and NetNews
3.1.3 NetNews Guidelines
Reply With Quote