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.

5
  • (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.) Commented Nov 14, 2015 at 4:10
  • 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
    Commented Nov 14, 2015 at 4:19
  • Telnet isn't secure... So what is secure mode? Commented Nov 14, 2015 at 5:58
  • Sorry for wording it badly, i was talking about Failsafe mode wiki.openwrt.org/doc/howto/generic.failsafe
    – Webodan
    Commented Nov 14, 2015 at 12:01
  • 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
    Commented Nov 14, 2015 at 12:10

2 Answers 2

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

2
  • 1
    I 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." Commented Nov 14, 2015 at 19:10
  • 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.
    – user
    Commented Nov 25, 2015 at 16:04
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).

1
  • 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
    Commented Nov 14, 2015 at 12:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .