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

Post new topic   This topic is locked: you cannot edit posts or make replies.    DD-WRT Forum Index -> General Questions
Goto page 1, 2  Next
Author Message
Alozaros
DD-WRT Guru


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

PostPosted: Tue Jun 07, 2022 21:43    Post subject: [SOLVED] Save script(more than one line via SSH Reply with quote
Hi guys....after update R7800 to 49113...with no reset...
my ad-blocker is not loading the host list...
wc -l /tmp/dlhosts
0 /tmp/dlhosts

however on my 1043v2 with same settings its working ok...so, i would like to add more sleep time to the usb script to try...

so, i would like to be able to edit/save .rc_usb script via SSh....how do i do that...?

i already tried to
nvram set=rc_usb=/opt/etc/init.d/rc.unslung start
sleep 15
sh /tmp/.rc_custom

but while pasting it, its in 3 lines and it hangs and than the nvram value is incomplete, so how must i paste/spell it to be able to be correct value in the nvram or if there is another way...to do it??

Im not physically able to access the unit, so no GUI access..!!

Thanks in advance...!!

_________________
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
Sponsor
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14126
Location: Texas, USA

PostPosted: Tue Jun 07, 2022 21:52    Post subject: Reply with quote
What is the output of nvram show | grep rc_usb= on your TL-WR1043NDv2? That should give you an idea of where your mistake is or how to type it out instead of copy/paste...
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
Alozaros
DD-WRT Guru


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

PostPosted: Tue Jun 07, 2022 22:01    Post subject: Reply with quote
both the same if i go trough nvram show | grep usb=
it shows only the 1-st line
where nvram show output shows the correct 3 lines
rc_usb=/opt/etc/init.d/rc.unslung start
sleep 10
sh /tmp/.rc_custom

so, i want to change sleep to 15
what would be the correct syntax when you have 3 line's Smile
as if i try to paste it as a 3 lines, it doesn't work it saves only the first line and the other 2 are missing Rolling Eyes

can i do it in one/single line like
nvram set=rc_usb=/opt/etc/init.d/rc.unslung start; sleep 15; sh /tmp/.rc_custom

_________________
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
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14126
Location: Texas, USA

PostPosted: Tue Jun 07, 2022 22:51    Post subject: Reply with quote
I have a feeling some magic voodoo is required, as nvram set rc_usb= should probably include information in quotation marks. I have a feeling it may not work properly as
Code:
nvram set rc_usb="/opt/etc/init.d/rc.unslung start
sleep 10
sh /tmp/.rc_custom"


Looking at the code, it removes the winblows <cr>ud from the input box in the webUI:

https://github.com/mirror/dd-wrt/blob/442e8579e4aafff44cca6767d39e757fecbfed98/src/router/httpd/validate/webs.c#L1425

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
Alozaros
DD-WRT Guru


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

PostPosted: Tue Jun 07, 2022 23:08    Post subject: Reply with quote
hmm it did work 10x... exactly with double quotes...as you suggested... Cool
so, this is the format to change the other scripts too.. custom and start up Wink

_________________
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
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14126
Location: Texas, USA

PostPosted: Tue Jun 07, 2022 23:26    Post subject: Reply with quote
I guess I was "wrong" about it not likely working EmbarassedRolling Eyes. Thanks for confirmation, and you're welcome Cool Wink
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
Alozaros
DD-WRT Guru


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

PostPosted: Wed Jun 08, 2022 0:02    Post subject: Reply with quote
yep it's ok, but sadly it's not the source of my issue..it turned up wget throws error on R7800...not the sleep time...i'll do more tests tomorrow... 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: Wed Jun 08, 2022 7:01    Post subject: Reply with quote
Alozaros wrote:
can i do it in one/single line like
nvram set=rc_usb=/opt/etc/init.d/rc.unslung start; sleep 15; sh /tmp/.rc_custom


this cant be right ok. I keep seeing this equals sign after nvram set since your first post.

there is no = after nvram set idk if that's a typo idk why you're posting it as is, maybe too many cups of tea? wait, dont answer that.

Should be as follows just copy and pasta and should be good to go.

Code:
nvram set rc_usb="/opt/etc/init.d/rc.unslung start; sleep 15; sh /tmp/.rc_custom" && nvram commit


confirm with

nvram show | grep rc_usb

_________________
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)


Last edited by the-joker on Wed Jun 08, 2022 7:04; edited 1 time in total
ho1Aetoo
DD-WRT Guru


Joined: 19 Feb 2019
Posts: 2927
Location: Germany

PostPosted: Wed Jun 08, 2022 7:03    Post subject: Reply with quote
Alozaros wrote:

so, i would like to be able to edit/save .rc_usb script via SSh....how do i do that...?

Im not physically able to access the unit, so no GUI access..!!

Thanks in advance...!!



i just wanted to say if you have ssh access then you also have GUI access ...

Code:
ssh -L1600:localhost:80 -Nv root@192.168.1.1 -p 22


this creates a ssh tunnel and the WebIF of the router is then accessible under the address 127.0.0.1:1600

apparently also works with putty or whatever

https://wiki.freifunk.net/SSH/Tunnel_mit_PuTTY



7945669999.jpg
 Description:
 Filesize:  71.27 KB
 Viewed:  1583 Time(s)

7945669999.jpg


egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12837
Location: Netherlands

PostPosted: Wed Jun 08, 2022 7:14    Post subject: Reply with quote
+1 for the Joker

Alternatively:
myvar=$(echo -e "/opt/etc/init.d/rc.unslung start\nsleep 15\nsh /tmp/.rc_custom\n")
nvram set rc_usb="$myvar"
nvram commit

nvram see: https://wiki.dd-wrt.com/wiki/index.php/Hardware

Note the "" otherwise it will stop at the first space

_________________
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: 6410
Location: UK, London, just across the river..

PostPosted: Wed Jun 08, 2022 9:44    Post subject: Reply with quote
just to recap...
KP-69 way its working as it should...

nvram set rc_usb="/opt/etc/init.d/rc.unslung start
sleep 10
sh /tmp/.rc_custom"

than i can see the results are present in the (1043v2)GUI too (my testing unit ATM), all in the same order of 3 lines...same as the output as on nvram show

to Joker..
if you follow the thread, you will find out, my amusement that, the output of nvram show | grep rc_usb is as its supposes to be, it will show you only the first line...but not all of the rc_usb script ...
and yep that extra = in my post above was a typo Embarassed Rolling Eyes
and yep your way also works and than its present in GUI and executed as it should...

nvram set rc_usb="/opt/etc/init.d/rc.unslung start; sleep 15; sh /tmp/.rc_custom"

to egc thanks, ill explore this option, i tried something similar with echo, but with no avail, now the kp-69 & Joker ways works..for me..but ill keep this in mind...thanks anyway..good to learn something new...

to ho1Aetoo yep this was my initial thought...of "forwarding the GUI via putty"...but it doesn't work as it should...as, i access via WANSSh, i have some GUI restriction rules, my GUI is via 443 local and stubby on the loopback...I need to fiddle around and redesign some rules...i guess...do i have to add an iptables line for forwarding the wanssh port to the local port..?

so far, on R7800@49113, wget is giving me an error, so in my case, i don't think usb script timing will help....

root@R7800:/tmp# wget http://download1.dd-wrt.com/dd-wrtv2/downloads/betas/2022/06-07-2022-r49113/tplink_tl-wr1043nd-v2/tplink_tl-wr1043nd-v2.bin

Connecting to download1.dd-wrt.com (xx.xx.x.xxx:xx)
wget: server returned error: HTTP/1.1 404 Not Found

unit works as it should, apart of wget...although i don't see any gremlins in nvram show, i need to do a reset and manual rebuild...probably, but me not present there physically to the R7800, i will wait...

wget works ok on my 1043v2 on 49113...(yep of course it will work...R7800 ISP bill not paid and they stopped port 80 http and their DNS, but im using curl(443) and DoT on this unit..so false alarm bloody GF forgot to pay the bill...girls.. Evil or Very Mad

i may try to use another adblocker with curl or modify the current script...
i need to fiddle around...and do some more testing...

_________________
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


Last edited by Alozaros on Wed Jun 08, 2022 12:06; edited 2 times in total
ho1Aetoo
DD-WRT Guru


Joined: 19 Feb 2019
Posts: 2927
Location: Germany

PostPosted: Wed Jun 08, 2022 11:34    Post subject: Reply with quote
no there must be only a port open which is forwarded to ssh

for example 22 to 22
the local port for example 8080 is created on your PC

but i use ssh on my pi hole since that supports ed25519 and access the routers from there
but this also works if you access the ssh of the router directly
Alozaros
DD-WRT Guru


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

PostPosted: Wed Jun 08, 2022 12:20    Post subject: Reply with quote
ho1Aetoo wrote:
no there must be only a port open which is forwarded to ssh

for example 22 to 22
the local port for example 8080 is created on your PC

but i use ssh on my pi hole since that supports ed25519 and access the routers from there
but this also works if you access the ssh of the router directly


hmmm lets say im using port 44444 for WAN ssh what i need to tunnel in putty than ?

Also if your PI supports ed25519, last time (not long ago) i also tried to add ed25519 to R7800 and it was not working, is ed25519 working now???

I do remember BS did some dropbear update to the last version, but i tried ed25519 and was not going...

if i generate a key (with puttygen) like this one, using ed25519 and paste it in R7800 GUI like that...
it was not working when i tried...Embarassed how do you do that...what im missing

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOO40Ms0aFEU99IcBc0XJ23Ff9D1CLOxMqu3dnk/AgPN eddsa-key-20220408

_________________
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
ho1Aetoo
DD-WRT Guru


Joined: 19 Feb 2019
Posts: 2927
Location: Germany

PostPosted: Wed Jun 08, 2022 13:26    Post subject: Reply with quote
No the router itself does not support ed25519 ... I have not claimed Wink

Quote:
hmmm lets say im using port 44444 for WAN ssh what i need to tunnel in putty than ?


https://wiki.freifunk.net/SSH/Tunnel_mit_PuTTY

As shown there.
Set up a regular ssh connection: remote address + port 44444

and then create a tunnel

Source port= is the port on your PC for example 8080 (everything above 1023)

Destination= localhost:80 or 192.168.1.1:80 (also works with any other device on the LAN)

if you have to click something else i don't know because i don't use putty

i usually use the linux terminal

Code:
ssh -L8080:localhost:80 -Nv root@Alozaros.dyn.dns -p 44444


But the ssh limitation can be a problem.
Since one tunnel opens multiple connections.
the-joker
DD-WRT Developer/Maintainer


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

PostPosted: Wed Jun 08, 2022 15:37    Post subject: Reply with quote
Alozaros wrote:
just to recap...
KP-69 way its working as it should...

nvram set rc_usb="/opt/etc/init.d/rc.unslung start
sleep 10
sh /tmp/.rc_custom"

than i can see the results are present in the (1043v2)GUI too (my testing unit ATM), all in the same order of 3 lines...same as the output as on nvram show

to Joker..
if you follow the thread, you will find out, my amusement that, the output of nvram show | grep rc_usb is as its supposes to be, it will show you only the first line...but not all of the rc_usb script ...
and yep that extra = in my post above was a typo Embarassed Rolling Eyes
and yep your way also works and than its present in GUI and executed as it should...

nvram set rc_usb="/opt/etc/init.d/rc.unslung start; sleep 15; sh /tmp/.rc_custom"

Your amusement as you noted is due your choices(you forget this is Linux?), 1) because you were not adding the "" to envelop the lot, and 2) because you decided to make the job harder by making it all in separate lines after following the advice to enclose the lot in "" You found out the long way around, how to get there, and getting there is all it matters, this isnt a race. (having said that race thing immediately thought "The Rat Race" Movie with Mr Bean Wink Or RoeRow to his friends.

I configure my router via CLI in fact using a script these days and in fact it is along the lines of what egc suggested using variable, except, I dont recommend using variables for instance in startup commands/firewall scripts or any other scripts stored to nvram, because it add extra size without actually being all that useful, one liners are better where every byte matters, in fact you dont need spaces after the delimiters `;` so less is more.

But scripting in general works better with settings variables and functions, because it is more flexible, depending on the end case.

Glad you sorted it, so today you learned something new, just think what you may learn tomorrow Wink I also learned something new, that Lighthtpd.asp/HLighthtpd.asp are a DD-WRT mystery.

Marking this as solved.

PS... I would keep it in one line rather than 3, less is more when it comes to nvram stored stuff, but if you have plenty nvram space left then by all means, it looks prettier all in its own line.

_________________
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)


Last edited by the-joker on Fri Aug 05, 2022 13:51; edited 2 times in total
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   This topic is locked: you cannot edit posts or make replies.    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