Page 1 of 1
[SOLVED] Dispatcher script doesn't work.
Posted: 04 Jun 2019, 17:00
by babam
How to get /etc/NetworkManager/dispatcher.d/XXX.sh to work.
Code: Select all
$ ls -l /etc/NetworkManager/dispatcher.d/01-test.sh
-rwxr-xr-x 1 root root 81 May 31 10:16 /etc/NetworkManager/dispatcher.d/01-test.sh
Code: Select all
$ cat /etc/NetworkManager/dispatcher.d/01-test.sh
#!/bin/bash
if [ "$2" = "up" ]; then
echo "$2" > /tmp/test.txt
elif [ "$2" = "down" ]; then
echo "$2" > /tmp/test.txt
fi
After disconnecting/connecting Wifi/Ethernet connection.
Code: Select all
$ cat /tmp/test.txt
cat: /tmp/test.txt: No such file or directory
Thanks.
Dispatcher script doesn't work
Posted: 04 Jun 2019, 20:00
by Ed_P
What happens if $2 is not "up" and not "down"?
Maybe something like this would work better.
Code: Select all
#!/bin/bash
if [ "$2" == "up" ] || [ "$2" == "down" ]; then
echo "$2" > /tmp.test.txt
else
echo "$2 is not up or down" > /tmp/test.txt
fi
And make sure your .sh file is executable.
Dispatcher script doesn't work
Posted: 04 Jun 2019, 22:49
by babam
Ed_P wrote: ↑04 Jun 2019, 20:00
What happens if $2 is not "up" and not "down"?
Maybe something like this would work better.
Code: Select all
#!/bin/bash
if [ "$2" == "up" ] || [ "$2" == "down" ]; then
echo "$2" > /tmp.test.txt
else
echo "$2 is not up or down" > /tmp/test.txt
fi
Still doesn't work
Code: Select all
$ cat /tmp/test.txt
cat: /tmp/test.txt: No such file or directory
Ed_P wrote: ↑04 Jun 2019, 20:00
And make sure your .sh file is executable.
Code: Select all
$ ls -l /etc/NetworkManager/dispatcher.d/01-test.sh
-rwxr-xr-x 1 root root 81 May 31 10:16 /etc/NetworkManager/dispatcher.d/01-test.sh
Dispatcher script doesn't work
Posted: 05 Jun 2019, 04:04
by Ed_P
If you manually run the 01-test.sh script from the command line do any errors show up? If not try "01-test.sh xx on" and "01-test.sh xx off" and "01-test.sh xx yy", each followed with a "ls -l /tmp"
Dispatcher script doesn't work
Posted: 05 Jun 2019, 04:17
by babam
Dispatcher script doesn't work
Posted: 05 Jun 2019, 18:42
by Ed_P
So, the test.sh script works it just doesn't work in /etc/NetworkManager/dispatcher.d/. Why that is I have no idea. Sorry.
Dispatcher script doesn't work
Posted: 05 Jun 2019, 21:05
by Ed_P
[SOLVED] Dispatcher script doesn't work.
Posted: 07 Jun 2019, 05:13
by babam
@Ed_P, Thanks.
Strange, now the dispatcher script can work.
Code: Select all
# /etc/rc.d/rc.networkmanager restart
[SOLVED] Dispatcher script doesn't work.
Posted: 07 Jun 2019, 18:03
by Ed_P
What did you do to make it work?
[SOLVED] Dispatcher script doesn't work.
Posted: 09 Jun 2019, 21:17
by babam
Restart Networkmanager
Code: Select all
# /etc/rc.d/rc.networkmanager restart