0

I have a quite long Bash script I use to install Apache server environments including PHPmyadmin and several other utilities, after logging to the remote machine via SSH. I run the script via the Ubuntu server 16.04 CLI terminal.

When the script runs, it stops sometimes, about 5-6 times to ask for password (whether in Unix itself or in some installation programs it starts).

Is there a way to make sure a sound notification will be played in each such stop whether in Unix itself or when a new installation program is initiated?


Update for SYN:

I did:

   82  sudo apt install alsa-utils
   83  speaker-test -t sine -f 1000 -l 1

And got:

speaker-test 1.1.0

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Sine wave rate is 1000.0000Hz
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4771:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM default
Playback open error: -2,No such file or directory

  • 1
    How are you running the script? Simplest would be adding `echo -e "\a"` for a good old bell, if that plays a sound however depends on your terminal (emulator). In KDE's konsole, you can e.g. define the bell behaviour in "Settings -> Configure Notifications ... ". Alternatively you could play a sound e.g. via ALSA's `aplay /path/to/file.wav`, i.e. an actual "play sound file command". I assume you are able to add lines to the script, though. – FelixJN Nov 12 '16 at 14:23
  • I am running the script via coping all it's contents into a file I create in-place via cd ~ && nano ses.sh && chmod +x ses.sh... After creating it I just do ./ses.sh. –  Nov 12 '16 at 15:26
  • Sorry for having been unclear. What kind of terminal are you using? Are you in a GUI environment or a CLI system? – FelixJN Nov 12 '16 at 15:29
  • Oh sorry for not mentioning (will now edit the question): I use the Bash shell (via CLI), under Ubuntu 16.04... –  Nov 12 '16 at 15:31
  • That would be `gnome-terminal` in standard configuration then. What feedback does `echo -e "\a"` (or `echo -e \\a`) give you? If no bell is heard, is the checkmark set under "Edit -> Profile Preferences -> General -> Terminal Bell"? – FelixJN Nov 12 '16 at 16:29
  • It's an Ubuntu server so I don't have a GUI at all but in any case both of these echo directives don't play a sound for me (tried several times with different amplitudes --- There is just no sound)... –  Nov 12 '16 at 16:33
  • Sorry, I misunderstood you there. Have you checked if you are able to play sounds at all? Maybe use `mplayer` to play an `mp3` file or use `play file.mp3` from the `sox` package. Of course there is a difference between using the PC speaker or an actual audio jack. – FelixJN Nov 12 '16 at 16:38
  • I think on post-install Ubuntus, you'll have alsa-utils, which comes with speaker-test, that you could use such as `speaker-test -t sine -f 1000 -l 1`. While the `echo "\a"` or tools like `beep` are useless. – SYN Nov 12 '16 at 17:38
  • 1
    @SYN I've updated the question regarding your comment. I guess my server hardware doesn't allow sound at all. –  Nov 12 '16 at 17:45
  • I didn't realize this was an Ubuntu server. Then `echo -e "\a" >/dev/console` *should* work after loading `pcspkr` (don't forget adding it to `/etc/modules`, assuming it fixed). You can purge speaker-test, apologies. – SYN Nov 12 '16 at 17:59
  • Can you please write a stepped answer with directives of what you suggest me to try @SYN ? Would gladly thumb up and accept if worked. –  Nov 12 '16 at 19:13

1 Answers1

0

Try this:

# modprobe pcspkr
# echo -e "\a" >/dev/console

If you didn't hear a sound... Are we sure you do have a piezo speaker in there? Otherwise, continue with loading pcspkr on boot:

# echo pcspkr >>/etc/modules
SYN
  • 2,793
  • 12
  • 19
  • Sadly both options doesn't work. Allow me to note I log in via SSH with Putty (now added this to question). Might that be associated? –  Nov 12 '16 at 19:33
  • I'm sorry.... I'm now realizing you're using SSH.... Well no, you can't produce sound on your local speaker from a remote command. – SYN Nov 12 '16 at 19:34
  • Wow... I didn't even imagine it would matter... I thought the sound output would just pass to my PC. Thank you ! –  Nov 12 '16 at 19:49
  • Nop. So far, I've been explaining you how to make your remote server beep, ... There would be ways to install some "sound server" on your workstation, and having remote hosts sending their audio in there, ... but it's not really obvious, and I'm not sure how relevant it would be setting such client up on a server. Sorry :\ – SYN Nov 12 '16 at 19:59