64

I'm using some Bash scripts under Linux that require some time to complete; I'd like to add at the end of them a command to ring the system bell when those tasks are done, so I can be notified.

What's the proper command to do that? (please note that what I need is to be notified, with a sound and possibly with a message, so I can accept any solution in these regards).

Sekhemty
  • 9,166
  • 18
  • 60
  • 97
  • 11
    Downvoting without an explanation is not very useful... – Sekhemty Sep 06 '15 at 14:19
  • http://unix.stackexchange.com/q/1974/1932 – paradroid Sep 06 '15 at 14:19
  • 3
    These solutions aren't working for me. – Sekhemty Sep 06 '15 at 14:27
  • 5
    What does your research tell you? What *exactly* have you tried and what didn't work? – slhck Sep 06 '15 at 14:41
  • Check this answer, http://unix.stackexchange.com/questions/1974/how-do-i-make-my-pc-speaker-beep – MariusMatutiae Sep 06 '15 at 16:34
  • I've tried the commands given on the answers to the linked question, but they aren't working – Sekhemty Sep 06 '15 at 20:19
  • 4
    `( speaker-test -t sine -f 440 )& pid=$! ; sleep 0.4s ; kill -9 $pid` requires ALSA installed. Always [from one of that answers](http://unix.stackexchange.com/a/163716/66388) – Hastur Sep 08 '15 at 13:20
  • I think you can find interesting an answer [about notification of slhck](http://superuser.com/a/345455/257269); the second part. – Hastur Sep 08 '15 at 13:30
  • Thanks to everyone, I tried to reinstall ALSA and now it works. I don't know why, but even it if was installed before, it didn't work; if someone wants to put their suggestions on these commands on a full answer, I can upvote and accept it. – Sekhemty Sep 18 '15 at 12:49

2 Answers2

75
tput bel

is a relatively portable solution.

gnucchi
  • 881
  • 5
  • 7
30

Try this command:

echo -e "\07"

or

echo -e "\a"

They are the same. "07" is an octal representation of BEL (bell) character in ASCII, and "a" stands for "alert", the letter is probably easier to remember. As mentioned in the comments, the -e switch enables escape sequences. Also, you can append a message directly after the escape character like this: "\aSuccess!".

Rolnik
  • 1,677
  • 2
  • 16
  • 28