0

I'm trying to get the Network Manager dispatcher to run a script when the network interface comes up or goes down. I want to execute an espeak command when the connection goes up or goes down. I can get it to write to the file /tmp/log but I don't hear any sound from the espeak command even though I can type it directly on the terminal and it works.

The way I test it is by disconnecting my usb network card (this is the only network card I have in the machine)

I've place the executable file in /etc/NetworkManager/dispatcher.d (it's called 02-ifupdowntest)

-rwxr-xr-x 1 root root 2293 Mar 26  2018 01-ifupdown
-rwxr-xr-x 1 root root  534 Jan 23 16:42 02-ifupdowntest
-rwxr-xr-x 1 root root 5383 Mar 27  2018 99tlp-rdw-nm

See contents of 02-ifupdowntest below:

#!/bin/bash -e
if [ "$2" = "up" ]; then

    echo "`date`" > /tmp/log
    echo "$1" >> /tmp/log
    echo "$2" >> /tmp/log
    echo "`/usr/bin/espeak "network up"`"

fi

if [ "$2" = "down" ]; then
    echo "$2" >> /tmp/log
    echo "`/usr/bin/espeak "network down"`"


fi

exit 0

I'm using Ubuntu 18.04 64bit Linux

  • Your quoting around the espeak command seems wrong. – Panki Jan 24 at 12:04
  • @Panki if I copy and pasted it to the terminal it works. I also tried taking out the double quotes... If it's wrong what should it be? – Rick T Jan 25 at 7:58
  • Why do you echo the command? By just writing /usr/bin/espeak "something" should do the job. You don't need to echo the command. – annahri Jan 27 at 22:11
  • @annahri that didn't work. – Rick T Jan 28 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.