What's new

My experience with the RT-AC86U

  • 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!

I cannot quite explain how my log ended up like this but it must have something to do with my Windows machine.

I mean - look at the carriage return symbols. I think I have spoiled the script with an accidental CR character. Possibly the 2 parts of the log are concatenated from 2 different runs and one of them is a broken script.
Try copying and pasting directly from Chrome here into an SSH editor like PuTTY?
 
I copied and pasted from Notepad++ into a nano window in PuTTY.
I don't see a CR in Notepad++ but this error in the log is typical when there's a carriage return in a shell script.
Must be Windows' copy-paste problem and it's in the bottom.

Disregard the log I attached initially, it's probably flawed and I couldn't reproduce it in 10 attempts.
The script simply stops at get nvram with no error message.
 

Attachments

  • CheckNewLinesInLoop.png
    CheckNewLinesInLoop.png
    25.4 KB · Views: 55
You certainly earned the gold star of the day for coming up with creative troubleshooting solutions!! :cool:
My gold star might just get more interesting....
try this:

Code:
#!/bin/sh
trap '' HUP INT QUIT ABRT TERM EXIT
(i="0"
while [ "$i" -le "2000" ]; do
  i="$(( i + 1 ))"
  for nv in 1 2 3 4 5; do unset "state$nv"; done
  state1="$(/bin/nvram get vpn_client1_state)"
  state2="$(/bin/nvram get vpn_client2_state)"
  state3="$(/bin/nvram get vpn_client3_state)"
  state4="$(/bin/nvram get vpn_client4_state)"
  state5="$(/bin/nvram get vpn_client5_state)"
  clear
  echo "$state1" "$state2" "$state3" "$state4" "$state5"
  [ "$i" -eq "2001" ] && i="0"
  echo "$i"
done) > /tmp/mynvramerror.log 2>&1 &

exit 0
 
Last edited:
My gold star might just get more interesting....
try this:

Code:
#!/bin/sh
trap '' HUP INT QUIT ABRT TERM EXIT
(i="0"
while true; do
  i="$(( i + 1 ))"
  for nv in 1 2 3 4 5; do unset "state$nv"; done
  state1="$(/bin/nvram get vpn_client1_state)" || true
  state2="$(/bin/nvram get vpn_client2_state)" || true
  state3="$(/bin/nvram get vpn_client3_state)" || true
  state4="$(/bin/nvram get vpn_client4_state)" || true
  state5="$(/bin/nvram get vpn_client5_state)" || true
  clear
  echo "$state1" "$state2" "$state3" "$state4" "$state5"
  echo "$i"
done) > /tmp/mynvramerror.log 2>&1 &

exit 0
Nope... it's being quite the stickler today!

1655157349460.png
 
I checked one more thing: what if I completely removed any attached USB media and rebooted.
The loop stopped "reliably" between 2000 and 4000 every single time, 5 out of 5 tries.
 
I checked one more thing: what if I completely removed any attached USB media and rebooted.
The loop stopped "reliably" between 2000 and 4000 every single time, 5 out of 5 tries.
I took this into consideration and I revised my one above to have a while loop with defined limits. @Viktor Jaep try my new revised one from the previous post. With the new suggestions..
 
I took this into consideration and I revised my one above to have a while loop with defined limits. @Viktor Jaep try my new revised one from the previous post. With the new suggestions..
This one ran to 1820 and locked up. :( I'll try running it again to see if it can get beyond 2000
 
I took this into consideration and I revised my one above to have a while loop with defined limits. @Viktor Jaep try my new revised one from the previous post. With the new suggestions..
So it looped past 2000...
1655158756511.png


Then it locked up at 891 the 2nd time through...

1655158794073.png
 
This one ran to 1820 and locked up. :( I'll try running it again to see if it can get beyond 2000
Here is new one to try

Code:
#!/bin/sh
trap '' HUP INT QUIT ABRT TERM EXIT
(i="0"
while [ "$i" -le "2000" ]; do
  i="$(( i + 1 ))"
  for nv in 1 2 3 4 5; do unset "state$nv"; done
  sleep 1 && state1="$(/bin/nvram get vpn_client1_state)"
  sleep 1 && state2="$(/bin/nvram get vpn_client2_state)"
  sleep 1 && state3="$(/bin/nvram get vpn_client3_state)"
  sleep 1 && state4="$(/bin/nvram get vpn_client4_state)"
  sleep 1 && state5="$(/bin/nvram get vpn_client5_state)"
  sleep 1 && clear
  echo "$state1" "$state2" "$state3" "$state4" "$state5"
  [ "$i" -eq "2001" ] && i="0"
  echo "$i"
done) > /tmp/mynvramerror.log 2>&1 &

exit 0
 
Here is new one to try

Code:
#!/bin/sh
trap '' HUP INT QUIT ABRT TERM EXIT
(i="0"
while [ "$i" -le "2000" ]; do
  i="$(( i + 1 ))"
  for nv in 1 2 3 4 5; do unset "state$nv"; done
  sleep 1 && state1="$(/bin/nvram get vpn_client1_state)"
  sleep 1 && state2="$(/bin/nvram get vpn_client2_state)"
  sleep 1 && state3="$(/bin/nvram get vpn_client3_state)"
  sleep 1 && state4="$(/bin/nvram get vpn_client4_state)"
  sleep 1 && state5="$(/bin/nvram get vpn_client5_state)"
  sleep 1 && clear
  echo "$state1" "$state2" "$state3" "$state4" "$state5"
  [ "$i" -eq "2001" ] && i="0"
  echo "$i"
done) > /tmp/mynvramerror.log 2>&1 &

exit 0
That's probably going to take some time to error out... I'll keep my eye on it
 
That's probably going to take some time to error out... I'll keep my eye on it
I have an ugly hack as well

Code:
#!/bin/sh
trap '' HUP INT QUIT ABRT TERM
trap 'sh $0' EXIT ERR
(i="0"
while [ "$i" -le "2000" ]; do
  i="$(( i + 1 ))"
  for nv in 1 2 3 4 5; do unset "state$nv"; done
  sleep 1 && state1="$(/bin/nvram get vpn_client1_state)" || continue
  sleep 1 && state2="$(/bin/nvram get vpn_client2_state)" || continue
  sleep 1 && state3="$(/bin/nvram get vpn_client3_state)" || continue
  sleep 1 && state4="$(/bin/nvram get vpn_client4_state)" || continue
  sleep 1 && state5="$(/bin/nvram get vpn_client5_state)" || continue
  sleep 1 && clear
  echo "$state1" "$state2" "$state3" "$state4" "$state5"
  [ "$i" -eq "2001" ] && i="0" || continue
  echo "$i"
done) > /tmp/mynvramerror.log 2>&1 &

exit 0
 
That's why I asked how to use milliseconds.
I wanted to give the CPU time to breathe but 1 sec pauses made the script too slow.
The result was that pauses didn't seem to improve reliability. Loop still hanged up at around the same number of iterations.
Tried with sleep of about 0.05 to 0.2 sec.
 
Last edited:
What isn't working on this router as a result of this bug? Is it Stock/Merlin or 384/386 base firmware specific?
 
What isn't working on this router as a result of this bug? Is it Stock/Merlin or 384/386 base firmware specific?
It's been happening since 384 I believe... scripts will hang when using a "nvram get" statement randomly.
 
For me, this is not completely random. Very often the loop stops between 2500 and 3200 iterations.
Doesn't matter how much time I give between the iterations.
Is there any cache involved in reading the nvram? Anything that can run out? Anything we could flush?
 
What if you guys install strace from Entware and prepend strace to the nvram command? See where the output ends.
Code:
strace nvram get ...
 
It's been happening since 384 I believe... scripts will hang when using a "nvram get" statement randomly.

This is strange. The router is quite old. No one noticed something is off? It was a popular router few years back.
 
It's been happening since 384 I believe... scripts will hang when using a "nvram get" statement randomly.
try this one if you get the chance.
Code:
#!/bin/sh
trap '' HUP INT QUIT ABRT TERM
(i="0"
while true; do
  i="$(( i + 1 ))"
  for nv in 1 2 3 4 5; do
  unset "state${nv}";
  eval "state${nv}"="$(/bin/nvram get vpn_client${nv}_state)";
  done
  clear
  echo "$state1" "$state2" "$state3" "$state4" "$state5"
  echo "$i"
done) > /tmp/mynvramerror.log 2>&1 &


exit 0

Edit: I revised it by removing the sleep 1.
After executing I ran tail -f /tmp/mynvramerror.log.

Heres a little more info about eval.

The eval command is used to execute the arguments as a shell command on unix or linux system. Eval command comes in handy when you have a unix or linux command stored in a variable and you want to execute that command stored in the string.


This is me ctrl+C out of the tail -f and it was still running.

1655166298133.png


I had to find the PID and kill -9 the process.
 
Last edited:

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

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