Tiny Core Linux
Tiny Core Base => Micro Core => Topic started by: mrstarr on November 25, 2015, 07: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://unix.stackexchange.com/questions/1974/how-do-i-make-my-pc-speaker-beep)
http://forum.tinycorelinux.net/index.php/topic,15098.msg86568.html#msg86568 (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:
#!/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
-
echo -ne "\007"
-
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?
-
The command I gave you works.
-
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...
(http://shellprompt.com/dump/DSC_9847.JPG)
(http://shellprompt.com/dump/DSC_9848.JPG)
Speaker:
(http://shellprompt.com/dump/DSC_9849.JPG)
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... :-/
-
Thanks for testing echoing a bell char out on your terminal and confirming it works. Not sure why mine isn't working :-/
(http://shellprompt.com/dump/DSC_9850.JPG)
(http://shellprompt.com/dump/DSC_9855.JPG)
-
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.
-
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!
-
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 (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 (https://www.youtube.com/watch?v=55zL2xMFbBs)
How do I uninstall oss and alsa (the easy way preferably)?
-
$ 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. :-(
-
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).
-
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...
-
Final Bash Script:
#!/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
-
For future reference, this works for me:
echo -ne '\007' > /dev/tty0
Change tty0 to your tty.