Technical issues/questions of an intermediate or advanced nature.
-
babam
- Warlord

- Posts: 528
- Joined: 16 Nov 2016, 10:30
- Distribution: Porteus 5.0rc3 Xfce K6.1.1
- Location: Rainy city
Post#1
by babam » 04 Jun 2019, 17:00
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.
Last edited by
babam on 07 Jun 2019, 05:16, edited 1 time in total.
Sorry, my English is bad.
babam
-
Ed_P
- Contributor

- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Post#2
by Ed_P » 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
And make sure your .sh file is executable.
Ed_P
-
babam
- Warlord

- Posts: 528
- Joined: 16 Nov 2016, 10:30
- Distribution: Porteus 5.0rc3 Xfce K6.1.1
- Location: Rainy city
Post#3
by babam » 04 Jun 2019, 22:49
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
Sorry, my English is bad.
babam
-
Ed_P
- Contributor

- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Post#4
by Ed_P » 05 Jun 2019, 04:04
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"
Ed_P
-
babam
- Warlord

- Posts: 528
- Joined: 16 Nov 2016, 10:30
- Distribution: Porteus 5.0rc3 Xfce K6.1.1
- Location: Rainy city
Post#5
by babam » 05 Jun 2019, 04:17
Sorry, my English is bad.
babam
-
Ed_P
- Contributor

- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Post#6
by Ed_P » 05 Jun 2019, 18:42
So, the test.sh script works it just doesn't work in /etc/NetworkManager/dispatcher.d/. Why that is I have no idea. Sorry.

Ed_P
-
Ed_P
- Contributor

- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Post#7
by Ed_P » 05 Jun 2019, 21:05
Ed_P
-
babam
- Warlord

- Posts: 528
- Joined: 16 Nov 2016, 10:30
- Distribution: Porteus 5.0rc3 Xfce K6.1.1
- Location: Rainy city
Post#8
by babam » 07 Jun 2019, 05:13
@Ed_P, Thanks.
Strange, now the dispatcher script can work.
Code: Select all
# /etc/rc.d/rc.networkmanager restart
Sorry, my English is bad.
babam
-
Ed_P
- Contributor

- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Post#9
by Ed_P » 07 Jun 2019, 18:03
What did you do to make it work?
Ed_P
-
babam
- Warlord

- Posts: 528
- Joined: 16 Nov 2016, 10:30
- Distribution: Porteus 5.0rc3 Xfce K6.1.1
- Location: Rainy city
Post#10
by babam » 09 Jun 2019, 21:17
Restart Networkmanager
Code: Select all
# /etc/rc.d/rc.networkmanager restart
Sorry, my English is bad.
babam