Missing last character when doing cat /tmp/.rc_usb

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page 1, 2  Next
Author Message
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1855
Location: Hung Hom, Hong Kong

PostPosted: Sat May 14, 2022 8:00    Post subject: Missing last character when doing cat /tmp/.rc_usb Reply with quote
Attached is the screen-shot. Notice the difference in the last line of each edit-box. One character was missing.

I dunno whether it's just one character or one line... Something to do with Line-Feed and Carriage-Return?

Counting? That a C for-loop in the source codes started with 1 not 0??




dd-wrt.screen.jpg
 Description:
 Filesize:  155.74 KB
 Viewed:  3072 Time(s)

dd-wrt.screen.jpg



_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw


Last edited by mwchang on Sat May 14, 2022 8:10; edited 3 times in total
Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12835
Location: Netherlands

PostPosted: Sat May 14, 2022 8:04    Post subject: Reply with quote
Do not use the command shell use the CLI (telnet/Putty)
_________________
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
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1855
Location: Hung Hom, Hong Kong

PostPosted: Sat May 14, 2022 8:11    Post subject: Reply with quote
egc wrote:
Do not use the command shell use the CLI (telnet/Putty)

It should be an easy fix, like last time when I reported an error related to escaping HTML characters in the same function Admin->Commands ... Smile


_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
the-joker
DD-WRT Developer/Maintainer


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

PostPosted: Sat May 14, 2022 8:55    Post subject: Reply with quote
If it should be an easy fix, it should be easy to submit a patch then Wink right ? hahahaha Wink

TBH, admin->commands is basic and not surprisingly so, not a substitute for a full blown terminal.

And what the hell is going on with that theme on screenshot... wow... speechless. Crying or Very sad

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


Joined: 26 Mar 2013
Posts: 1855
Location: Hung Hom, Hong Kong

PostPosted: Mon May 16, 2022 5:09    Post subject: Reply with quote
the-joker wrote:
TBH, admin->commands is basic and not surprisingly so, not a substitute for a full blown terminal.

Inexperienced users still rely on Administration->Commands to "Save USB", "Save Startup"... for scripting, and for simple management tasks. This function exists for a long time...


_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw


Last edited by mwchang on Mon May 16, 2022 5:26; edited 1 time in total
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1855
Location: Hung Hom, Hong Kong

PostPosted: Mon May 16, 2022 5:25    Post subject: Reply with quote
the-joker wrote:
If it should be an easy fix, it should be easy to submit a patch then Wink right ? hahahaha Wink

It still will take hard work and precious time. Maybe later... Smile

Side-note: I think source codes of DD-WRT lacked sufficient documentation and comments. This adds difficulties reading codes let alone fixing problems for new developers. Anyway...


_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
the-joker
DD-WRT Developer/Maintainer


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

PostPosted: Mon May 16, 2022 7:06    Post subject: Reply with quote
Well, I agree with lack of proper comments but that is 90% or more of any projects.

Not being a C person, thus not being familiar with most of its functions and declarations, I understand the pain.

That said all code is code even scripting languages all have some common ancestry in one way or another similarities exist, some syntax can change and or have specific quirks but its all code.

If you can read one, you can more or less read another, and the internet being the internet, I can search for any portions I dont understand what its doing to see what documentation says.

One recent example was fopen() regarding snmp.c service file, after searching the intranets this popped up https://www.tutorialspoint.com/c_standard_library/c_function_fopen.htm sure enough there was light.

I'm already on the 5th chapter of my life and have some impairment due to health issues that affects my brain most days, so learning new stuff is extra extra hard and remembering stuff is also bullshit.
But my health issues are not me, the self is resilient and one must soldier on and forward without fear or hesitation no matter what it is about.

Time however is one thing once expended you never get back, so I try to use it wisely, not always possible as this posts attests to. Wink

sorry for the ramble.

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


Joined: 18 Mar 2014
Posts: 12835
Location: Netherlands

PostPosted: Mon May 16, 2022 7:15    Post subject: Reply with quote
C is actually quite easy, as a starter I like Beej's guide:

https://beej.us/guide/bgc/

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


Joined: 26 Mar 2013
Posts: 1855
Location: Hung Hom, Hong Kong

PostPosted: Mon May 16, 2022 7:35    Post subject: Reply with quote
the-joker wrote:
One recent example was fopen() regarding snmp.c service file, after searching the intranets this popped up https://www.tutorialspoint.com/c_standard_library/c_function_fopen.htm sure enough there was light.

In another thread, I found that DD-WRT Busybox was not including the flock command. It could be as useful as a simple fopen() and it shouldn't take much disk space. You could lock a file like using a semaphore. Anyway... Wink

Regarding your ramble: our brains are born to grow old. Some age faster, some slower.


_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw


Last edited by mwchang on Mon May 16, 2022 7:38; edited 1 time in total
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1855
Location: Hung Hom, Hong Kong

PostPosted: Mon May 16, 2022 7:37    Post subject: Reply with quote
egc wrote:
C is actually quite easy, as a starter I like Beej's guide:
https://beej.us/guide/bgc/

I knew C. What I needed was time, mood and patience to read the source of DD-WRT. Thanks! Smile


_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
the-joker
DD-WRT Developer/Maintainer


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

PostPosted: Mon May 16, 2022 10:10    Post subject: Reply with quote
I think there is some stripping going on.

First, most files have an empty line at the end I think thats likely being stripped out.
Second, to test whats going on, I ran
Code:
cat /tmp/dnsmasq.conf


The empty line at end of file is not rendered, and in addition, maybe because its a web interface its interpreting other stuff like in file I have an entry like dhcp-option=252,"\n" followed by cache-size=1500 on the very next line.

This is shown then as

Code:
dhcp-option=252,"
"
cache-size=1500


So indeed the web interface is interpreting the new line and rendering it.

This tells me the logic behind is likely if you ran a cat on some html file that would render the HTML instead of showing the actual text.

I havent tested this, but I know for instance, when there are crashes on some router page the backtrace will output what was on page and if it includes html like e.g. input, that an actual input is rendered and looks like any input on regular options page, and you can interact with it, like type text into that input on the syslsog page -- right, its nuts!

On an aside note, there is a fully fledged web terminal based on xterm that could be used as a wrapper for the busybox terminal functionality see https://github.com/xtermjs/xterm.js and use that instead of the current solution, obviously would need to be neutered to suit dd-wrt as most the stuff wouldn't be needed.

That would give you essentially the same functionality in web interface as running it from a real terminal, but without its caveats as well since its only a wrapper and not actual terminal, but, your not actually gonna notice those shortcomings.

The only drawback of this is, the project has quite a few dependencies, and boy oh boy its dependency hell any such projects, though size wise its minimal.

Anyway it was a brain fart, I doubt it would actually be integrated.

better solution would be to fix the shortcomings.

Problem is JS is not BS's cup'o tea, and I'm also limited.

_________________
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)
the-joker
DD-WRT Developer/Maintainer


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

PostPosted: Mon May 16, 2022 10:28    Post subject: Reply with quote
Yep, running cat on a html file renders most of the html intead of showing the files contents, same as I observed in syslog.

See attachment and marvel at the 999th wonder of the world.

Not a simple fix after all.



wut.gif
 Description:
 Filesize:  351.16 KB
 Viewed:  2820 Time(s)

wut.gif



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


Joined: 26 Mar 2013
Posts: 1855
Location: Hung Hom, Hong Kong

PostPosted: Mon May 16, 2022 12:25    Post subject: Reply with quote
the-joker wrote:
Yep, running cat on a html file renders most of the html intead of showing the files contents, same as I observed in syslog.
See attachment and marvel at the 999th wonder of the world.
Not a simple fix after all.

I didn't expect this. Smile

The simple solution is to always wrap the output of shell execution with "<Pre>" or "<TextArea>" tag? Worth trying in my opinion...

If I remember correctly, the last time I reported problem about Admin -> Commands was the output of "cat /proc/mtd".


_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
the-joker
DD-WRT Developer/Maintainer


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

PostPosted: Mon May 16, 2022 12:36    Post subject: Reply with quote
mwchang wrote:
I didn't expect this. Smile

The output is always wrapped in the pre, just look at Diagnostics.asp source to confirm, makes no difference whatsoever to any issues in this part.

There are bigger issues then the last line being missing is all I'm saying.

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


Joined: 26 Mar 2013
Posts: 1855
Location: Hung Hom, Hong Kong

PostPosted: Mon May 16, 2022 12:39    Post subject: Reply with quote
the-joker wrote:
The output is wrapped in the pre, just look at Diagnostics.asp source, makes no difference.

There are bigger issues then the last line being missing is all I'm saying.

How about just replacing "<" with "&lt;" and ">" with "&gt;"? I think the problem with quote characters was solved when I reported about "cat /proc/mtd". Find that same function and add logic to escape "<" and ">"?

Which characters need to be escaped in HTML? - Stack Overflow
https://stackoverflow.com/questions/7381974/which-characters-need-to-be-escaped-in-html

How to escape & unescape HTML characters in string in JavaScript
https://www.educative.io/edpresso/how-to-escape-unescape-html-characters-in-string-in-javascript

JavaScript escape() Method
https://www.w3schools.com/jsref/jsref_escape.asp


_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware 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