alarm sound when something is put in a file

Posted on 2002-05-08
Last Modified: 2010-04-21
Let us say I have a process that is running and appending some text at the end of a file so using the following command

tail -f myFile | grep alarmText        ----(1)

I will get a line of output whenever the alaramText is put on the file.

What I want is some kind of alarming sound (such as the one you get when someone initiates a "talk command" with your name), so that I will be able to know when that thing happend instead of shifting my attention and going at the xterm I am running (1).
Question by:oumer
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 51

Expert Comment

ID: 6997344
tail myFile |(grep alarmText && /bin/echo "\007")

Author Comment

ID: 6999659
first of all thanks for letting me know to use /bin/echo cause I was using just echo ,which was in /usr/bin and it doesn't work with the bell sound. but still there is some problem with the code you sent. I still get a text message but no sound. but when i tried /bin/echo "\007" the alarm sounds ok.

I wrote a small script called

while [ "$x" -ne 100 ]
/bin/echo "\007"
let x=x+1

which will just sound the bell 100 times and it works alone perfectly

then  I used

tail -f myFile |(grep alarmText &&

the output i get is the same as

tail -f myFile | grep alarmText

(I am using -f since I want to create endless check)

so I think the && ing is not working. What do you think is the problem?


Author Comment

ID: 6999665
but doing something like
echo "hi" && echo "bye" works (I mean as a standalone command without the piping and everything)
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 51

Expert Comment

ID: 6999705
oops, the grep command never exits (as long as the pipe is open), so the following command does not exectute, that's the reason.

The simplest solution would be to modify your in that way that it gets the input, does a grep and bells. Then call it like:

   tail -f myFile |
LVL 84

Expert Comment

ID: 7000375
tail -f myFile | perl -pe 's/(alarmText)/\a$1\a/'

Author Comment

ID: 7001194
i still don't get it how to return from the grep even in the alarm file, cause it seems it is constantly getting input and never returning (because of the tail piping)

and ozo,
I tried your code it doesn't work
LVL 51

Accepted Solution

ahoffmann earned 50 total points
ID: 7001217
#! /bin/ksh
while read line; do
    \echo "$line"|grep alarmText && /bin/echo "\007"

then use
   tail -f myFile |

works for me.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question