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

From: Jolet, John (John.Jolet@MISYSHEALTHCARE.COM)
Date: Tue Jun 25 2002 - 09:40:24 EDT


maybe have them hit a different key sequence and issue "kill -9 tailpid" in
your script? have to capture the pid of the tail process, though.

-----Original Message-----
From: Robert Bardos [mailto:Robert.Bardos@ZUGERKB.CH]
Sent: Tuesday, June 25, 2002 6:44 AM
To: aix-l@Princeton.EDU
Subject: Controlled exit from 'tail -f' within a shell script

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