1

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

Rick T
  • 357

0 Answers0