Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 2090  / 1 Year ago, thu, march 30, 2023, 12:46:45

How can i make beep sound in the PC when the network cable is unplugged or no network available to any specific interface such as eth0 or eth1?



Follow up:



$ sudo apt-get install beep
$ cat /etc/modprobe.d/blacklist.conf | grep 'pcspkr'
blacklist pcspkr
$ sudo vim /etc/modprobe.d/blacklist.conf
#blacklist pcspkr
:wq
$ sudo modprobe pcspkr
$ beep

More From » 12.04

 Answers
4

You're not going to want to keep wgetting infinitly to know if you have network:
what you are looking for is a "post-up" script. This is kinda advanced, but you should be able to do this.



First, figure out how to make a sound. You can use the methods @iUngi uses, like echo -e or beep.



To actually add this beeping to the point where you have network, use the information at https://wiki.ubuntu.com/OnNetworkConnectionRunScript



The part you are interested in (but read the whole thing!) is this:




Edit the text configuration file /etc/network/interfaces and add one
of the following directive pre-up , post-up , pre-down , post-down to
the appropriate network connection, for example :



auto eth0

iface eth0 inet dhcp

name WiFi

post-up
/etc/network/if-up.d/myscript.sh



restart your network:



/etc/init.d/networking restart




You can obviously add an extra check ping for instance or just get the headers (curl --head) if your connection isn't always on internet but can be a local connection (and you don't want a beep then), but I think that shouldn't be needed in all cases.


[#34323] Friday, March 31, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
steaocyte

Total Points: 345
Total Questions: 122
Total Answers: 121

Location: Spain
Member since Wed, Nov 23, 2022
1 Year ago
steaocyte questions
;