[SOLVED - AGAIN]Format for setting multi-line nvram values

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Fri Sep 16, 2022 7:12    Post subject: [SOLVED - AGAIN]Format for setting multi-line nvram values Reply with quote
If I'm in an SSH session for dd-wrt and I want to set an nvram value that contains newlines, what is the proper way to do that?

I know that if I'm setting something that is a single line with no spaces, I don't need quotes, i.e.:

Code:
nvram set some_key=singlevalue


and if I'm setting values that contain spaces, then I need to add quotes:

Code:
nvram set list_ips="192.168.1.1 192.168.1.3"


But if I've got something that has newlines in it, like say the pptpd_auth key, then what is the proper way to enter that? As long as I put an opening quote, can I hit enter as needed like in a typical linux shell and it will continue the line?

Code:

nvram set pptpd_auth="bruce * pass1 *<ENTER>
bob * pass2 *<ENTER>
alice * pass3 *"<ENTER>


I'd just try it, but I don't want to mess anything up and thought I would ask first.
Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12834
Location: Netherlands

PostPosted: Fri Sep 16, 2022 7:23    Post subject: Reply with quote
Just try it with a non existent nvram variable you can unset it when done testing

But yes it should work

I use:
nvram set test="$(echo -e 'newline 1\nnewline 2\n')"

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6407
Location: UK, London, just across the river..

PostPosted: Fri Sep 16, 2022 8:48    Post subject: Reply with quote
this way works for me either nvram or in GUI

/opt/etc/init.d/rc.unslung start; sleep 10; sh /tmp/.rc_custom


there was a request i made once .. but couldn't find the thread atm
there ware few other options offered too.. Cool

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55179 WAP
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55460 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55460 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55363 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Fri Sep 16, 2022 9:44    Post subject: Re: Format for setting multi-line nvram values Reply with quote
brucehvn wrote:
and if I'm setting values that contain spaces, then I need to add quotes

This is Linux, so quotes are necessary for multiple entries/lines.

_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
dale_gribble39
DD-WRT Guru


Joined: 11 Jun 2022
Posts: 1899

PostPosted: Fri Sep 16, 2022 11:26    Post subject: Reply with quote
Alozaros wrote:
there was a request i made once .. but couldn't find the thread atm
there ware few other options offered too.. Cool

This one?

[SOLVED] Save script(more than one line via SSH

How could I forget your welcoming spirit <lol>

_________________
"The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep." - Robert Frost

"I am one of the noticeable ones - notice me" - Dale Frances McKenzie Bozzio

<fact>code knows no gender</fact>

This is me, knowing I've ruffled your feathers, and not giving a ****
Some people are still hard-headed.

--------------------------------------
Mac Pro (Mid 2012) - Two 2.4GHz 6-Core Intel Xeon E5645 processors 64GB 1333MHz DDR3 ECC SDRAM OpenSUSE Leap 15.5
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6407
Location: UK, London, just across the river..

PostPosted: Fri Sep 16, 2022 11:44    Post subject: Reply with quote
dale_gribble39 wrote:
Alozaros wrote:
there was a request i made once .. but couldn't find the thread atm
there ware few other options offered too.. Cool

This one?

[SOLVED] Save script(more than one line via SSH

How could I forget your welcoming spirit <lol>


Thanks 4 finding it dale_gribble39... I'm obsequiously flattered now Razz Cool Laughing

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55179 WAP
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55460 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55460 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55363 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Fri Sep 16, 2022 23:37    Post subject: Reply with quote
@Alozaros, I was looking over that old thread and I saw the issue you were having with wget. Did you try quoting the URL to see if wget would then retrieve it properly?
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Fri Sep 16, 2022 23:43    Post subject: Reply with quote
Thanks everyone for your responses. I wrote a perl script to parse a dump from an
Code:
nvram show


and I wanted to make an option to have it output all of them as properly formatted
Code:
nvram set xxxxx
lines.

I certainly wouldn't use that to restore an entire backup, but there are some items that are a little tedious to reconfigure when wiping nvram like static leases, wi-fi mac filters, port forwards, etc., that being able to just copy and paste via the CLI would make easier.
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6407
Location: UK, London, just across the river..

PostPosted: Sat Sep 17, 2022 8:48    Post subject: Reply with quote
brucehvn wrote:
@Alozaros, I was looking over that old thread and I saw the issue you were having with wget. Did you try quoting the URL to see if wget would then retrieve it properly?


wget works as intended it was a user error.. as ISP blocks port 80 http if i don't pay my bill on time Razz

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55179 WAP
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55460 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55460 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55363 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Sat Sep 17, 2022 16:52    Post subject: Reply with quote
brucehvn wrote:
Thanks everyone for your responses. I wrote a perl script to parse a dump from an
Code:
nvram show


and I wanted to make an option to have it output all of them as properly formatted
Code:
nvram set xxxxx
lines.

I certainly wouldn't use that to restore an entire backup, but there are some items that are a little tedious to reconfigure when wiping nvram like static leases, wi-fi mac filters, port forwards, etc., that being able to just copy and paste via the CLI would make easier.


You can script that to restore the desired nvram entries, its what I do essentially, but my script is a bit fast and loose not something Im going to share at this time.

Essentially I set those entries with corresponding values as variables with for loop to iterate through them. Works TM.

_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum