Controlled exit from 'tail -f' within a shell script

From: Robert Bardos (Robert.Bardos@ZUGERKB.CH)
Date: Tue Jun 25 2002 - 07:44:15 EDT


Hi all,

I am new to this list (and new to AIX, new to shell scripts ....) so please
bear with me.
My intention is to provide our operators with a simple, telnet based tool
that allows them to start/stop some subsystems and to watch these
subsystems' logs continuously. And: as an exercise for myself I want to do
it all with shell scripts.

So basically the logic is:

  do while true
      echo selection screen
      read user_selection
      case "$user_selection" in
           x) tail -f my_log_file
           .....
      esac
      ....
  done

According to the man(ual) and some tests 'tail -f' can only be ended by
pressing ctrl-c.
This also cancels my shell script which is not the desired effect. (I
experimented with the trap command but to no avail). Any idea how I can
limit ctrl-c to just the 'tail -f' command?

Should there be a more appropriate list for this kind of question then
please advise.

Thanks in advance
Robert





This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:00 EDT