WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How do I get microcore to sound a System Bell Beep?  (Read 9541 times)

Offline mrstarr

  • Newbie
  • *
  • Posts: 20
How do I get microcore to sound a System Bell Beep?
« on: November 25, 2015, 04:03:06 AM »
I can't get my microcore installation to sound a system beep (Control-G) from the BASH shell to save my life.

I installed alsa with 'ab' app browser.  Plugged speakers into external speaker jack (just in case there was no onboard pc speaker).  What else can I try?  What else do I need to install?  Is there any other way to make sound?  (or how else can I kludge around this so I get some kind of audible or other alert from a monitor/headless pc short of having it email another device(grr))

http://unix.stackexchange.com/questions/1974/how-do-i-make-my-pc-speaker-beep

http://forum.tinycorelinux.net/index.php/topic,15098.msg86568.html#msg86568


What I am trying to do, is write a Ping Monitoring Bash script, that will ping the IP of my servers about every minute and beep if any one of them is down:

Code: [Select]
#!/bin/bash

#   script to ping ip of servers and check if they are up or down, and beep if they aren't
#   usage:
#   ./check_hosts.sh google.com yahoo.com 192.168.1.2 mylinuxbox N2100

#   ./check_hosts.sh 71.226.8.1 192.168.2.1 192.2.11 192.168.1.1 192.168.2.3

while :
do
for i in $@
do
ping -c 1 $i &> /dev/null

if [ $? -ne 0 ]; then
echo "`date`: ping failed, $i host is down!"
echo -ne '/07'       # beep = echo -ne '/07'
fi
done
sleep 60
done
« Last Edit: November 25, 2015, 04:09:53 AM by mrstarr »

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: How do I get microcore to sound a System Bell Beep?
« Reply #1 on: November 25, 2015, 05:56:16 AM »
echo -ne "\007"

Offline mrstarr

  • Newbie
  • *
  • Posts: 20
Re: How do I get microcore to sound a System Bell Beep?
« Reply #2 on: November 25, 2015, 10:29:37 AM »
Flipping the slash \/ didn't help.     With or without external speakers plugged in.

I just found the on board speaker, so that verifies that at least exists.

What package contains the "beep" command, maybe that would help.  AB "contains" search did not turn up anything.

I installed oss, oss-alsa, and alsa...

Also, is there a simple way to generate a sound, like a simple way to play a .wav or other sound type file...  with those sound packages installed?

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: How do I get microcore to sound a System Bell Beep?
« Reply #3 on: November 25, 2015, 10:44:00 AM »
The command I gave you works.

Offline mrstarr

  • Newbie
  • *
  • Posts: 20
Re: How do I get microcore to sound a System Bell Beep?
« Reply #4 on: November 25, 2015, 10:53:16 AM »
Pictures of my 5 year old Microcore Webserver/Samba server, running on a fanless HP5135 (400mghz, 110mb RAM, 8 watts), that this script would run on.    These pictures are hosted on same webserver pictured...





Speaker:




I have 7 wifi routers and boxes on a 10 acre farm, that are all linked together in a string in what I call RadioLan... to get high speed internet from one end of the farm to the other (over a field, across a pond, through a yard, etc).   To get high speed internet at the furthest point, a packet goes through a Linksys Wifi Router connected to a DWL-2100 ap, which is connected (for upstream internet) as client to Cisco Wifi router, which itself is connected to a DWL-2100 as client, which is connects to a Belkin configured as AP, which itself connects to Dlink Gaming router, then Cablemodem (then network gateway).   

Of course, if any one of these networking wifi boxes goes down, and since they are all a mishmash of consumer grade hardware, exposed to extremes of temperature and interference... well...   reliability is less than optimal.

I polished my ping kludge script in initial post to actually work (yeah I know original post code is rife with errors, I was typing from memory, can't copy and paste from microcore box) and format output nicely and it works great... except I need an audible alert if one box don't respond, so then I can turn on the monitor, and see which it is.

There is a Win equivalent of such an app called Peer Monitor, and it works just as great, but it'd be great if I could use my script on the microcore all solid state box since its on 24/7/365 already.


Micocore has worked great on this box all these years.  Sometimes the webserver on the microcore box dies for no reason, and httpd -restart won't work cause of locked sockets, so I have to reboot it with "sudo reboot" or cntrl alt delete every two weeks or so.  Have yet to figure out why... :-/ 

Offline mrstarr

  • Newbie
  • *
  • Posts: 20
Re: How do I get microcore to sound a System Bell Beep?
« Reply #5 on: November 25, 2015, 11:27:24 AM »
Thanks for testing echoing a bell char out on your terminal and confirming it works.  Not sure why mine isn't working :-/




Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: How do I get microcore to sound a System Bell Beep?
« Reply #6 on: November 25, 2015, 11:33:44 AM »
Tiny Core booted from USB stick I can produce a beep on my tower PC but not on my netbook.
So it might be a hardware incompatibility thing.
Download a copy and keep it handy: Core book ;)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10957
Re: How do I get microcore to sound a System Bell Beep?
« Reply #7 on: November 25, 2015, 11:46:02 AM »
If you have speakers connected, OSS includes ossplay and ALSA includes aplay, both able to play wav files. Only install one sound system at a time!
The only barriers that can stop you are the ones you create yourself.

Offline mrstarr

  • Newbie
  • *
  • Posts: 20
Re: How do I get microcore to sound a System Bell Beep?
« Reply #8 on: November 25, 2015, 01:00:48 PM »
I have ossplay installed, I just checked from shellprompt. 
I tried "ossplay doorbell.wav" from the command line with a wav file.  ( http://soundbible.com/165-Door-Bell.html)

I get this error: 
$ ossplay doorbell.wav
/dev/dsp : no such file or directory

The sound file device is missing from /dev
You should try reinstalling OSS.
$

Trying alsa's "aplay" gives the same error...  "can't open /dev/dsp"

Doing a "ls /dev | less" I see a /dev/audio, but no /dev/dsp existing

I rebooted, tried fresh with same error, then tried reinstalling oss with AB, but AB barfs and says oss already installed

In 1969 Nasa put a man on the moon, but in 2015 I can't even make a PC speaker beep :-(  *sigh*  Still grappling with the machine and pulling out hair on a shell prompt...  https://www.youtube.com/watch?v=55zL2xMFbBs

How do I uninstall oss and alsa (the easy way preferably)?

« Last Edit: November 25, 2015, 01:30:49 PM by mrstarr »

Offline mrstarr

  • Newbie
  • *
  • Posts: 20
Re: How do I get microcore to sound a System Bell Beep?
« Reply #9 on: November 25, 2015, 01:34:29 PM »
$ cat /proc/asound/pcm
00-00 : VIA 8327 : VIA 8327 : playback 4 : capture 1
00-01 : VIA 8327 : VIA 8327 : playback 1 : capture 1
$

Googling /dev/dsp missing isn't helping much.  Give me a few more hours banging my head against this !@#$%^, and I'll kludging an AM radio parked next to the box, volume on high, trying to create sounds old school by working the CPU in different loops.  :-(
« Last Edit: November 25, 2015, 01:51:17 PM by mrstarr »

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: How do I get microcore to sound a System Bell Beep?
« Reply #10 on: November 25, 2015, 01:46:51 PM »
Quote
How do I uninstall oss and alsa (the easy way preferably)?
Remove  oss.tcz  and/or  alsa.tcz  from  /etc/sysconfig/tcedir/onboot.lst .

For sound to work via ALSA, you may need  alsa-config.tcz  to be installed (listed in onboot.lst).
Download a copy and keep it handy: Core book ;)

Offline mrstarr

  • Newbie
  • *
  • Posts: 20
Re: How do I get microcore to sound a System Bell Beep?
« Reply #11 on: November 25, 2015, 01:57:48 PM »
SUCCESS!  

I edited /etc/sysconfig/tedir/onboot.lst     and ripped out alsa.tcz, alsa-oss.tcz, libao.tcz, and left oss.tcz
filetool.sh -b
rebooted

$ ossplay doorbell.wav    now works!  I don't even have to plug in speakers, doorbell.wav comes out of the onboard speaker.  Sounds like an old skool pinball thumper.  Couldn't be happier.

Thanks last poster :-)  And well all posters.   Geez Louise...
« Last Edit: November 25, 2015, 02:01:26 PM by mrstarr »

Offline mrstarr

  • Newbie
  • *
  • Posts: 20
Re: How do I get microcore to sound a System Bell Beep?
« Reply #12 on: November 25, 2015, 02:49:29 PM »
Final Bash Script:

Code: [Select]
#!/bin/bash

# NETWORK BOX MONITOR ping script
# simple bash script to ping ip of servers and check if they are up or down and beep if they aren't
# usage:
# name file checkhosts.sh and run from linux command line with  'sh checkhosts.sh'
# press control c to exit
# doorbell.wav or wav sound file of same file name needs to be in same dir, and oss.tsz needs to be installed
# pretty straight forward, modify and hack it up to suit your needs
# author: Mark Starr <mrstarr@nyx.net>   2015-11-25

# the doorbell.wav sound file can be found here:   http://soundbible.com/165-Door-Bell.html
# just download file, and rename to doorbell.wav and put in same dir as script

while :
do
clear
echo "NETWORK BOX MONITOR"
echo "Pinging Hosts every 60 seconds: press Control C to exit"
echo
date
echo
echo

# set x to equal y at any point in script if we want to play doorbell alert sound after all pinging is done. 
x="0"
y="1"

ping -c 1 71.226.8.1 &> /dev/null
if [ $? -ne 0 ]
then
echo " COMCAST DOWN <--"
x = "1"
else
echo " COMCAST Ok"
fi

ping -c 1 192.168.2.1 &> /dev/null
if [ $? -ne 0 ]
then
echo " AP1 DOWN <-- Dlink Gaming Router"
x = "1"
else
echo " AP1 Ok"
fi

ping -c 1 192.168.2.11 &> /dev/null
if [ $? -ne 0 ]
then
echo " AP11 DOWN <-- Belkin AP on Trailer Wall"
x = "1"
else
echo " AP11 Ok"
fi

ping -c 1 192.168.1.1 &> /dev/null
if [ $? -ne 0 ]
then
echo " AP3 DOWN <-- Linksys Router Parents Wall"
x = "1"
else
echo " AP3 Ok"
fi

ping -c 1 192.168.2.3 &> /dev/null
if [ $? -ne 0 ]
then
echo " AP6 DOWN <-- Linksys Router Little House"
x = "1"
else
echo " AP6 Ok"
fi


if [ "$x" = "$y" ]
then
ossplay "doorbell.wav"
                # alternatively, if you can get system bell to beep to work from a command line for you, you can substitute
                # echo -ne "\007" for ossplay statement above, and thereby not need to install oss
fi

sleep 60

done

« Last Edit: November 25, 2015, 03:18:30 PM by mrstarr »

Offline bela.d

  • Newbie
  • *
  • Posts: 8
Re: How do I get microcore to sound a System Bell Beep?
« Reply #13 on: April 10, 2019, 01:45:02 AM »
For future reference, this works for me:
Code: [Select]
echo -ne '\007' > /dev/tty0
Change tty0 to your tty.