What's new
  • 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!

Rogue variable in NVRAM

Akro

New Around Here
[SOLVED] Rogue variable in NVRAM

Can someone please help me to get rid of this rogue variable in NVRAM, short of clearing nvram?

I am running Asuswrt-Merlin v3.0.0.4.374.39_0 on an ASUS RT-AC66U.

Code:
admin@RT-AC66U:/tmp/home/root# nvram show | grep wl0.1_wpa_psk
=anothertrysk
size: 41956 bytes (23580 left)
admin@RT-AC66U:/tmp/home/root# nvram show | grep anothertry
size: 41956 bytes (23580 left)
=anothertrysk
admin@RT-AC66U:/tmp/home/root# nvram show | grep anothertrysk
size: 41956 bytes (23580 left)
admin@RT-AC66U:/tmp/home/root# nvram set wl0.1_wpa_psk=goawayplease
admin@RT-AC66U:/tmp/home/root# nvram commit
admin@RT-AC66U:/tmp/home/root# nvram show | grep wl0.1_wpa_psk
wl0.1_wpa_psk=goawayplease
=anothertrysk
size: 41983 bytes (23553 left)
admin@RT-AC66U:/tmp/home/root# nvram show | grep =anothertry
=anothertrysk
size: 41983 bytes (23553 left)
admin@RT-AC66U:/tmp/home/root#

I was trying to set the guest password for 'wl0.1_wpa_psk' using 'nvram set' when something went wrong. Now I have something in NVRAM that I can't get rid of.

As far as I can tell, there are some invisible characters embedded inside of 'wl0.1_wpa_psk=anothertrysk' as you can tell from the code posted above - please look at the 'grep' returns carefully.
 
Last edited:
Try unsetting it:

Code:
nvram unset wl0.1_wpa_psk
nvram commit

If it still fails, then it's probably corruption in your nvram content, not specifically with that particular setting.
 
Thanks for that RMerlin. I actually already tried that. I've since cleared the NVRAM and started over again (twice now since I managed to muck it up again).

Here is some more background information that may help to track down the cause and possible solution. Keep in mind, I'm not much good at SH Scripting.

I am using PLINK through Windows CMD to run a SH Script to set passwords for the Guest Networks. Something like this:

Code:
plink.exe -v -ssh %rHOST% -P %rPORT% -l %rUSER% -pw %rPASS% -batch $SHELL< "script.sh" >> logfile.txt

or 

plink.exe -v -ssh %rHOST% -P %rPORT% -l %rUSER% -pw %rPASS% -m "script.sh" >> logfile.txt

Inside 'script.sh' I have commands similar to the following, where {SETTING:WiFiPW} or simply {:WiFiPW} is a variable which is supposed to be substituted with a value such as 'newguestpassword'. (the variable is from another program - don't ask)

Code:
#!/bin/sh
guestnet24_1=wl0.1_wpa_psk
guestpwd24_1={SETTING:WiFiPW}
echo GUEST NETWORKS ...
gn1=`nvram show | grep "wl..._wpa_psk" | sort`
echo $gn1 | sed 's/ /\r\n/g'
echo --- Changing Password
nvram set $guestnet24_1=$guestpwd24_1

So basically:
Code:
nvram set wl0.1_wpa_psk={SETTING:WiFiPW}

Maybe when {SETTING:WiFiPW} (or {:WiFiPW}) hasn't been evaluated properly, the 'nvram set' command is setting some funky value into NVRAM, perhaps due to one or more of the symbols {, :, }. That is where my SH Scripting prowess falls apart, and I believe that caused my issue.

It may also be pertinent to note that PLINK is a bit strange when it comes to scripts. The '-m' option only accepts a certain amount of lines/characters before it fails ("FATAL ERROR: the server refused to execute connection/command"), and the '$SHELL<script.sh' redirection doesn't really seem to work (at least, the 'nvram commit' lines don't seem to properly execute). I think PLINK is actually stringing all the SH command lines from 'script.sh' into a single long line that it attempts to execute all at once, or something like that. Maybe it's this PLINK behavior or even the 'grep' command and pipes and such.

I wonder, can anyone suggest a free alternative to PLINK/PuTTY that might work better, which could be used in this case, executing from Windows CMD:
Code:
CMD > commands.bat > PLINK > script.sh > Router < log.txt
 
Last edited:
Well, I've done it again... this time using sexec from Bitvise, running this from a .bat file:

Code:
sexec.exe %rUSER%@%rHOST%:%rPORT% -pw=%rPASS% -tracelevel=1 -tracefile=%TRACEFILE% <test.sh >> %LOGFILE% 2>&1

Where 'test.sh' has this inside:

Code:
guestnet24_1=wl0.1_wpa_psk
guestnet50_1=wl1.1_wpa_psk
guestpwd24_1=bestfriends
guestpwd24_2=bestfriends
arg1=$1
echo 
echo Shell Script BEG `date +'%Y-%m-%d_%H.%M.%S'`
echo 
echo arg1 $arg1
echo n24_1 $guestnet24_1
echo n50_1 $guestnet50_1
echo p24_1 $guestpwd24_1
echo p50_1 $guestpwd50_1
echo 
echo 
echo GUEST NETWORKS ... 
echo 
gn1=`nvram show | grep wl..._wpa_psk | sort` 
echo 
echo $gn1 | sed 's/ /\r\n/g'
echo 
echo Setting password for $guestnet24_1 to $guestpwd24_1 ... 
nvram set $guestnet24_1=$guestpwd24_1
echo COMMITTING ...
#nvram commit
echo 
echo GUEST NETWORKS ...
gn2=`nvram show | grep wl..._wpa_psk | sort`
echo 
echo $gn2 | sed 's/ /\r\n/g'
exit

Here again is the problem output:

Code:
ASUSWRT-Merlin RT-AC66U_3.0.0.4 Fri Jan 31 05:20:23 UTC 2014
admin@RT-AC66U:/tmp/home/root# nvram show | grep wl..._wpa_psk | sort
size: 41975 bytes (23561 left)
=bestfriendsk
wl0.1_wpa_psk=goodfriends
wl0.2_wpa_psk=
wl0.3_wpa_psk=
wl1.1_wpa_psk=goodfriends
wl1.2_wpa_psk=
wl1.3_wpa_psk=
admin@RT-AC66U:/tmp/home/root#

Thankfully, I just rebooted and it the problem went away, since the 'nvram commit' line was commented out.
 
Last edited:
Here is the issue - there are embedded non-printing/invisible characters inside. I went in through PuTTY and turned on it's logging, and found this:

Code:
# nvram show | grep wl..1_wpa_psk
size: 44778 bytes (20758 left)
wl1.1_wpa_psk!={SETTING:WiFiPW}!!
wl0.1_wpa_psk!={SETTING:WiFiPW}!!
#

I've used the exclamation (!) as a placeholder for the invisible characters. It is represented by a musical 8th note in my editor, and under many fonts, the charmap says this is character U+266A. This link gives some information: http://www.fileformat.info/info/unicode/char/266a/index.htm

UTF-8 Hex: 0xE2 0x99 0xAA (e299aa)
UTF-16 Hex: 0x266A (266a)

Is there a proper syntax for something like:
Code:
nvram unset "wl1.1_wpa_psk!" or nvram unset 'wl1.1_wpa_psk!' or nvram unset (wl1.1_wpa_psk!) or 
nvram unset "wl1.1_wpa_psk(0x266A)"
... so that I might be able to copy/paste to the terminal window to achieve what I'm going for?
 
Last edited:
[SOLVED] Rogue variable in NVRAM

Code:
# nvram show | grep wl0.1_wpa_psk
wl0.1_wpa_psk=goodfriends
wl0.1_wpa_psk!={SETTING:WiFiPW}!!

# badstring=$(nvram show | grep "wl0.1_wpa_psk" | grep "SETTING")
# badchars=$(echo $badstring | sed 's/wl0.1_wpa_psk//g')
# badpart=$(echo $badchars | awk '{split($0,bad,"=")} END{print bad[1]}')
# nvram unset "wl0.1_wpa_psk$badpart"
# nvram commit
# nvram show | grep wl0.1_wpa_psk
wl0.1_wpa_psk=goodfriends
# nvram show | grep "SETTING"
#

Thank you for your assistance.
 
Last edited:
Similar threads
Thread starter Title Forum Replies Date
garycnew Asuswrt-Merlin Change Operation Mode Fails via NVRAM Variables Asuswrt-Merlin 15

Similar threads

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

Members online

Back
Top