What's new

Help with writing a simple "wl radio off && wl radio on" script!! please!!

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

so something like this/

"c8:2b:96:4e:b5:16|c8:2b:96:4e:e7:dd|c8:2b:96:4e:94:bb|2c:f4:32:e4:8b:7e|c8:2b:96:4e:b7:e5|c8:2b:96:4e:e4:24|c8:2b:96:4f:17:96|c8:2b:96:4e:df:6e|c8:2b:96:4e:b7:e4|c8:2b:96:4f:24:3a"
 
so something like this/

Code:
"c8:2b:96:4e:b5:16|c8:2b:96:4e:e7:dd|c8:2b:96:4e:94:bb|2c:f4:32:e4:8b:7e|c8:2b:96:4e:b7:e5c8:2b:96:4e:e4:24|c8:2b:96:4f:17:96|c8:2b:96:4e:df:6e|c8:2b:96:4e:b7:e4|c8:2b:96:4f:24:3a"
Seriously? :eek:, you felt the need to post this reply/query for clarification i.e. as an example of my instruction to use a string that doesn't contain spaces?

OK, programming tip....if you wish to make the long assignment statement more human friendly (so you can quickly edit/add/remove/reorganise/verify/ duplicate similar MACs far easier)

You can use the line continuation '\' method:
Code:
# Put the MACs each on its own line but they will be concatenated into a single contiguous/unbroken string
MAC_LIST="c8:2b:96:4e:b5:16|\
c8:2b:96:4e:e7:dd|\
c8:2b:96:4e:94:bb|\
2c:f4:32:e4:8b:7e|\
c8:2b:96:4e:b7:e5|\
c8:2b:96:4e:e4:24|\
c8:2b:96:4f:17:96|\
c8:2b:96:4e:df:6e|\
c8:2b:96:4e:b7:e4|\
c8:2b:96:4f:24:3a"
Alternatively, you can keep your one-liner embedded (multiple) space method, but ensure the script automatically removes the spaces when it executes:
Code:
# Define the variable with spaces for readability.....
MAC_LIST="c8:2b:96:4e:b5:16  |  c8:2b:96:4e:e7:dd  |  c8:2b:96:4e:94:bb  |  2c:f4:32:e4:8b:7e  |  c8:2b:96:4e:b7:e5  |  c8:2b:96:4e:e4:24  |  c8:2b:96:4f:17:96  |  c8:2b:96:4e:df:6e  |  c8:2b:96:4e:b7:e4  |  c8:2b:96:4f:24:3a"
MAC_LIST="$(echo "$MAC_LIST" | tr -d " ")"     # Remove embedded spaces

So just in case you are still baffled........

The deceptively simplistic command
Code:
DESC="$(echo "$SYSLOG" | grep -oE "$MAC_LIST")"
basically searches the contents of the most recent Syslog message (stored in variable "$SYSLOG") looking for a matching string (defined in "$MAC_LIST").

Now the really, really clever bit is
Code:
grep -oE "$MAC_LIST"
and breaking down the 1st argument '-oE'

i.e.
Code:
grep --help

Usage: grep [OPTION]... PATTERNS [FILE]...
Search for PATTERNS in each FILE.

Example: grep -i 'hello world' menu.h main.c
PATTERNS can contain multiple patterns separated by newlines.

Pattern selection and interpretation:
  -E, --extended-regexp     PATTERNS are extended regular expressions
  -o, --only-matching       show only nonempty parts of lines that match
So from the 'grep' help, the "-E" informs the 'grep' utility that the 2nd argument "$MAC_LIST" isn't a simple text string, but a powerful "Regex" (also sometimes called "Regexp") Pattern.

I'll let you Google regex (aka regexp) e.g. the main Wiki article and various online Regex tutorials and examples.

Code:
Hopefully you      will now   understand why the      special '|' delimiter character sequences in "$MAC_LIST" are       extremely important and,   unlike    in    this         sentence,        acknowledge that whitespace chars     are very significant, and will subtly alter the criteria for an exact regex match.
 
Last edited:
@Martineau , thanks for all the info, i really appreciate it. Just like you said, removing the spaces and all is working.

so after i made the "space" changes, as soon as i turned the script it worked like a charm:

Mar 23 09:19:23 (SyslogEventMonitor.sh): 5269 v1.03 Syslog Event monitor not running
Mar 23 09:19:33 (SyslogEventMonitor.sh): 5304 v1.03 Syslog Event Monitor started.....
Mar 23 10:19:33 dnsmasq-dhcp[946]: DHCPDISCOVER(br0) c8:2b:96:4e:df:6e
Mar 23 10:19:33 dnsmasq-dhcp[946]: DHCPOFFER(br0) 192.168.1.84 c8:2b:96:4e:df:6e
Mar 23 10:19:34 dnsmasq-dhcp[946]: DHCPDISCOVER(br0) 2c:f4:32:e4:8b:7e
Mar 23 10:19:34 dnsmasq-dhcp[946]: DHCPOFFER(br0) 192.168.1.91 2c:f4:32:e4:8b:7e
Mar 23 10:19:34 dnsmasq-dhcp[946]: DHCPDISCOVER(br0) c8:2b:96:4e:b7:e4
Mar 23 10:19:34 dnsmasq-dhcp[946]: DHCPOFFER(br0) 192.168.1.105 c8:2b:96:4e:b7:e4
Mar 23 10:19:34 dnsmasq-dhcp[946]: DHCPDISCOVER(br0) c8:2b:96:4f:24:3a
Mar 23 10:19:34 dnsmasq-dhcp[946]: DHCPOFFER(br0) 192.168.1.20 c8:2b:96:4f:24:3a
Mar 23 09:19:34 (SyslogEventMonitor.sh): 5304 Light Bulb Monitor Lightbulb DHCP detected c8:2b:96:4e:df:6e; Action='/jffs/scripts/Restart_Radio.sh'
Mar 23 09:19:34 (SyslogEventMonitor.sh): 5304 e-mail sent using curl smtps:// SSL/TLS (non-Certificate) mysmtp.server.com:nnn
Mar 23 09:19:34 (Restart_Radio.sh): 5368 1.01 Restarting Radio.....

but now i came back to my laptop and i see:

Mar 23 14:22:00 dnsmasq-dhcp[946]: DHCPDISCOVER(br0) c8:2b:96:4e:b7:e5
Mar 23 14:22:00 dnsmasq-dhcp[946]: DHCPOFFER(br0) 192.168.1.106 c8:2b:96:4e:b7:e5
Mar 23 14:22:02 dnsmasq-dhcp[946]: DHCPDISCOVER(br0) c8:2b:96:4e:b7:e5
Mar 23 14:22:02 dnsmasq-dhcp[946]: DHCPOFFER(br0) 192.168.1.106 c8:2b:96:4e:b7:e5
Mar 23 14:22:06 dnsmasq-dhcp[946]: DHCPDISCOVER(br0) c8:2b:96:4e:b7:e5



so i checked if the script is running but it was not and inside the logs i cant find anywhere where it says that the script got terminated or whatever, as soon as i started the script it worked like a charm again:

Mar 23 13:46:10 (SyslogEventMonitor.sh): 30964 v1.03 Syslog Event monitor not running
Mar 23 13:46:23 (SyslogEventMonitor.sh): 31005 v1.03 Syslog Event Monitor started.....
Mar 23 13:46:24 (SyslogEventMonitor.sh): 31005 Light Bulb Monitor Lightbulb DHCP detected c8:2b:96:4e:b7:e5; Action='/jffs/scripts/Restart_Radio.sh'
Mar 23 13:46:24 (SyslogEventMonitor.sh): 31005 e-mail sent using curl smtps:// SSL/TLS (non-Certificate) mysmtp.server.com:nnn
Mar 23 13:46:24 (Restart_Radio.sh): 31068 1.01 Restarting Radio.....


I dont know why the time changes but that irrelevant.

how do i get this script to stop shutting down and keep it running 24h?

I know i need to do ./services-start on startup every time I reboot but is there anything else I can do so it keeps on running?

Complete logs attached

Best regards,

Adam Popiel
 

Attachments

  • syslog (9).txt
    43.4 KB · Views: 115
Last edited:
how do i get this script to stop shutting down and keep it running 24h?

I know i need to do ./services-start on startup every time I reboot but is there anything else I can do so it keeps on running?
Hopefully, now that the script is working, you won't need to hack it to introduce bugs. :p

So if you are manually issuing
Code:
./SyslogEventMonitor.sh &
or
Code:
./services-start
to create the child background task, then when you logoff your SSH session, as your SSH session is the parent task, all of the child tasks you created are also terminated.

PEBCAK - Bang game-over.

The way that you ensure that the 'SyslogEventMonitor.sh' script remains running in the background is to have the router execute 'services-start' on your behalf during the boot process.

Please post the output of these commands.
Code:
ls -lah /jffs/scripts/services-start

cat /jffs/scripts/services-start

nvram get jffs2_scripts
NOTE: If 'services-start' matches the command shown in post #26 and NVRAM variable
Code:
jffs2_scripts=1
then simply REBOOT, and hopefully when you eventually logon via SSH issue
Code:
./SyslogEventMonitor.sh status
and it should show the background task running - Logoff/Logon and repeat until you are satisfied that the script does run permanently.

P.S. The 'stop' command is only used to aid interactive testing of a modified script such as when you add a new lightbulb MAC, but in normal use should not be required/used.

Rule of thumb, currently, if the background SyslogEventMonitor.sh script goes AWOL, you will always need a reboot to reinstate it as a persistent background task.

EDIT: I understand there is a simple patch available to allow creating a persistent background task from the command line :rolleyes: ? - but let's get the auto-start @boot resolved first!;)
 
Last edited:
@Martineau

here is the output:

ASUSWRT-Merlin RT-AC86U 384.15_0 Sat Feb 8 18:41:28 UTC 2020
apopiel85@RT-AC86U-61D0:/tmp/home/root# ls -lah /jffs/scripts/services-start
-rwxrwxrwx 1 apopiel8 root 41 Mar 22 09:52 /jffs/scripts/services-start
apopiel85@RT-AC86U-61D0:/tmp/home/root# cat /jffs/scripts/services-start
sh /jffs/scripts/SyslogEventMonitor.sh &
apopiel85@RT-AC86U-61D0:/tmp/home/root# nvram get jffs2_scripts
1



Everything works perfectly now. Thank you!! the script starts automatically after reboot.

Now I got one more for you. I got the Asus ac86u router, its a dual-band router. I have these lightbulbs on the 2.4g band
and when I'm connected to 2.4g on my phone, when I turn on the lightbulb the radio restarts and I briefly lose connection. So I wanted to do some testing and created a test guest 2.4wifi, and to my amazement, when I'm on the guest network and I turn on the lightbulb, the connection DOES NOT interrupt, which is weird because I thought "wl radio off & wl radio on" command it would turn off everything associated with 2.4g. So now my question to you is:

is this normal what I experienced?
ideally, I don't want to interrupt 2.4g because I let everyone from my wife to other guests use 2.4g so they don't steal my 5g speed. i know I'm horrible :)

based on my test 2.4g test I would just rename my regular 2.4g to something just for the lightbulbs and rename the guest to my regular 2.4g name and problem solved right?
but is it possible to do the wl radio off && wl radio on command for just the guest network? I'd rather have the lightbulbs on the guest network.
I know that the most ideal thing would be to have a tri-band router and just use one of the 2.4g for lightbulbs.
but like I said, I'm on the guest 2.4g wifi and it does not interrupt when I turn on the lightbulb, which leads me to believe that it's somehow separated from the regular 2.4g wifi, or maybe the command wl radio off/on is specific to just the regular 2.4g wifi

here is output from ifconfig - I know that I can turn off just the 5g wifi because that's the eth6 in my case but which one is the guest?

apopiel85@RT-AC86U-61D0:/tmp/home/root# ifconfig
bcmsw Link encap:Ethernet HWaddr 04:D4:C4:C1:61:D0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2555 errors:0 dropped:0 overruns:0 frame:0
TX packets:2061 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:439762 (429.4 KiB) TX bytes:247299 (241.5 KiB)
Base address:0xffff

br0 Link encap:Ethernet HWaddr 04:D4:C4:C1:61:D0
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING ALLMULTI MULTICAST MTU:1500 Metric:1
RX packets:37241 errors:0 dropped:36 overruns:0 frame:0
TX packets:51372 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4029639 (3.8 MiB) TX bytes:121744163 (116.1 MiB)

eth0 Link encap:Ethernet HWaddr 04:D4:C4:C1:61:D0
inet addr:217.120.209.126 Bcast:217.120.209.255 Mask:255.255.254.0
UP BROADCAST RUNNING ALLMULTI MULTICAST MTU:1500 Metric:1
RX packets:33202 errors:0 dropped:0 overruns:0 frame:0
TX packets:19722 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:35431951 (33.7 MiB) TX bytes:2563849 (2.4 MiB)


eth1 Link encap:Ethernet HWaddr 04:D4:C4:C1:61:D0
UP BROADCAST ALLMULTI MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)


eth2 Link encap:Ethernet HWaddr 04:D4:C4:C1:61:D0
UP BROADCAST ALLMULTI MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)


eth3 Link encap:Ethernet HWaddr 04:D4:C4:C1:61:D0
UP BROADCAST ALLMULTI MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)


eth4 Link encap:Ethernet HWaddr 04:D4:C4:C1:61:D0
UP BROADCAST ALLMULTI MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)


eth5 Link encap:Ethernet HWaddr 04:D4:C4:C1:61:D0
UP BROADCAST RUNNING ALLMULTI MULTICAST MTU:1500 Metric:1
RX packets:3462 errors:0 dropped:3 overruns:0 frame:0
TX packets:20299 errors:0 dropped:10 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:632632 (617.8 KiB) TX bytes:18451240 (17.5 MiB)

eth6 Link encap:Ethernet HWaddr 04:D4:C4:C1:61:D4
UP BROADCAST RUNNING ALLMULTI MULTICAST MTU:1500 Metric:1
RX packets:26288 errors:0 dropped:2 overruns:0 frame:0
TX packets:85508 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2583008 (2.4 MiB) TX bytes:107141632 (102.1 MiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MULTICAST MTU:65536 Metric:1
RX packets:24526 errors:0 dropped:0 overruns:0 frame:0
TX packets:24526 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5019426 (4.7 MiB) TX bytes:5019426 (4.7 MiB)

lo:0 Link encap:Local Loopback
inet addr:127.0.1.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MULTICAST MTU:65536 Metric:1

spu_ds_dummy Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00 -00-00
UP RUNNING NOARP MTU:3072 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

spu_us_dummy Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00 -00-00
UP RUNNING NOARP MTU:3072 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

wl0.1 Link encap:Ethernet HWaddr 04:D4:C4:C1:61:D1
UP BROADCAST RUNNING ALLMULTI MULTICAST MTU:1500 Metric:1
RX packets:2171 errors:0 dropped:0 overruns:0 frame:0
TX packets:8453 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:343101 (335.0 KiB) TX bytes:2702162 (2.5 MiB)

apopiel85@RT-AC86U-61D0:/tmp/home/root#


as always, thank you for everything and I'm looking forward to your reply :)


EDIT!!!!

don't reply to this post, after more testing,the guest wifi also turns off for a second when I turned on the lights :(
I guess I need a 3 band Asus router :)
 
Last edited:
don't reply to this post,
Yeah like that will stop me!:p
ideally, I don't want to interrupt 2.4g because I let everyone from my wife to other guests use 2.4g so they don't steal my 5g speed.

i know I'm horrible
Easily justifiable that this is your entitled prerogative/perk because of the rules ;)
Code:
1. I pay the bill.
2. I have the admin password.
3. Who do they turn to when the internet is DOWN (assuming you didn't cause it - but even if you did then refer to Rules 1 & 2).
Everything works perfectly now. Thank you!!
Glad my simple SyslogEventMonitor template script was eventually useful, although with hindsight it is probably only useful to give you time to identify the root cause - assuming you have the motivation to deal with the specific light bulb vendor (or does it happen with any brand of Smart Light Bulb?)

Good luck.
 
Last edited:
Glad my simple SyslogEventMonitor template script was eventually useful, although with hindsight it is probably only useful to give you time to identify the root cause - assuming you have the motivation to deal with the specific light bulb vendor (or does it happen with any brand of Smart Light Bulb?)

No, these lightbulbs were the first thing I tried getting from Ali express :) This issue only happens on these lightbulbs and when I tried contacting the seller about a FW update for them, he simply said "we no help u wit this" so I think I'm out of options here unless I open up a lightbulb up and see anything on the chip to identify its maker or whatnot. I have another smart bulb from a known brand Nedis and it works flawlessly with the app and everything, no issues with it what so ever, so I know it an issue with these crappy lightbulbs :). To be honest, now that I have it working, I think I'm just gonna leave it as is, and the next lightbulbs I but ill make sure they are either official stuff (expensive) or maybe a different Chinese brand with a different android app to see if It works out-of-the-box.
 
Last edited:

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top