editing text file in a telnet connection without text editor

2

I need to modify a text file inside a wifi audio receiver that runs OpenWRT, and i've reached the file i need in /etc/config/audio , and i have editing rights (i'm rebooting the device in secure mode so i'm root), but the darn thing doesn't have a text editor, of all things! i've tried vi, vim, emacs, joe, nano, but doesn't seem to have any. it does have echo, cat, grep and a few more but none are text editors.

I'm logging into it with PuTTY, and any other connection besides Telnet is refused. I hope somebody can help me.

Webodan

Posted 2015-11-14T04:03:55.723

Reputation: 39

(1) I suppose sed and awk are unlikely to be there, but have you checked for ed and ex?  (2) Can you download the file, edit it on your computer, and then upload it?  (If so, I suggest that you upload it with a different name, diff them to make sure nothing went wrong, and then either rename (mv) or copy (cp) the new file over the old file.) – G-Man Says 'Reinstate Monica' – 2015-11-14T04:10:46.407

there's ed but i don't know about ex or all the others. what i'm certain is that i don't know how to down/upload the file into/from my pc while telneting to the device within PuTTY. – Webodan – 2015-11-14T04:19:24.580

Telnet isn't secure... So what is secure mode? – Canadian Luke – 2015-11-14T05:58:41.373

Sorry for wording it badly, i was talking about Failsafe mode https://wiki.openwrt.org/doc/howto/generic.failsafe

– Webodan – 2015-11-14T12:01:44.323

and I know telnet is not secure but I can't use any other thing since the device rejects any other protocol i've tried in PuTTY. – Webodan – 2015-11-14T12:10:55.730

Answers

1

I've finally fixed it!

the command i needed was a mix of sed and find, which I found in a website and i'll post here;

find etc/config/audio -type f -exec sed -i 's/OLDNAME/NEWNAME/g' {} \;

this edited the particular file and it searched and replaced OLDNAME (which i replaced with the current parameter that the variable had), and NEWNAME (with the one i wanted to give it) and this worked like a charm.

whew

Webodan

Posted 2015-11-14T04:03:55.723

Reputation: 39

1I don't see why you would need to use find; if the command you posted works, then the direct invocation, sed -i 's/OLDNAME/NEWNAME/g' /etc/config/audio/filename, should work, too.  ... ... ... ... ... ... ...  P.S. I did mention sed in my first comment; I assumed that you had looked for it when you said "it does have ... a few more but none are text editors." – G-Man Says 'Reinstate Monica' – 2015-11-14T19:10:10.340

If this solved your problem, you may want to accept this answer which will indicate to the community that the question has been answered to your satisfaction. – a CVn – 2015-11-25T16:04:01.720

0

Use ed.  Read the GNU 'ed' Manual if you're not familiar with it (although if you know the : commands in vi, you're halfway there).

G-Man Says 'Reinstate Monica'

Posted 2015-11-14T04:03:55.723

Reputation: 6 509

I'm really sorry, couldn't check properly when i said that there was ed. No there isn't................ I wonder what else I can do. Thanks a lot for support – Webodan – 2015-11-14T12:02:17.957