What's new

Asus/Merlin Script Tutorial

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

If you are developing scripts, I highly recommend learning how to edit them on the router. It gets very cumbersome editing then copying them from your PC, running chmod to make them executable, etc.

I've used vi for so many years that it is second-nature. In fact, on my PC sometimes forget when using a full-screen editor (like Word or Notes) and type 'i' or 'a' before typing. And I find myself ending by hitting the <ESC> key. I often find I've entered ESC:wq when I'm finished and want to save the file and exit :)
Glad I'm not the only one! I tend to end up with 'ZZ' in my text ...
The vi installed (at least with the ASUS firmware) seems to be stripped-down compared to what I'm used to using.So there are some things I've had to learn not to do. I'm not aware of any other file editor native to the router. If so, what else is there?
You can always install vim through Entware, that's what I did.
Anyway, I highly recommend learning how to use the native editor(s) instead of copying scripts - especially during the debugging phase.
Here, here! vi - it's always there, it always works.
 
I am trying to start a program to run in the background - in my case a Rexx program.
I tried to put:
/usr/bin/nohup /opt/bin/transmission-throttle quiet &
into services-start , but at reboot it does not start.

Then I installed screen and tried
/opt/sbin/screen -dmS transmission-throttle bash -c '/opt/bin/transmission-throttle quiet; exec bash'

The first line of the script says:
#!/opt/bin/rexx

which exists when the system is up and running..

both of these work on my Linux systems.. However, neither worked. Any ideas why?

My only idea is that the /opt/ is not mounted yet, even with 30 seconds worth of 'sleep' I put before the above lines in this script. Shall I increase it? I don't want to delay the router's startup more than it might be necessary.

Many thanks, -t
 
Last edited:
@Turgut Kalfaoglu

Do these commands work when you run them from the command line?

The router doesn't have bash (unless you installed and configured it from Entware).

As you say, services-start is not a good place for your commands. It would be better to create a proper Entware start/stop script in /opt/etc/init.d
 
Glad I'm not the only one! I tend to end up with 'ZZ' in my text ...

You can always install vim through Entware, that's what I did.

Here, here! vi - it's always there, it always works.

I understand the reason people keep using vim, but isn’t it easier with nano that also comes by default with entware?
 
Agreed. But it is only fair to also inform them of the effort involved in learning. It's not just plug-and-play. They'll need to expend a good deal of effort and initiative.
Show us the path, where to start it, what steps to take and I will follow it. I need a curriculum.
I wish I could get some context: what commands to issue and why, where to issue them, when to issue them. and parentheses and the heirarchy of them. if-fi logic loops, do-done...til we get that stuff in our heads, we're all chef boyardee makin copypasta. is bash linux? bash is a shell...within linux?
I was a decent BASIC "programmer" back in junior high...then qnx came along in high school (which I shouldve stuck with and looks familiar to some of what happens around here), but I shifted to the arts before getting into C+ at that stage, and went forward without looking back. now it seems necessary, and increasingly so. I can probably compare some of what's happening in code to what I know of electronic components, functionality-wise, and that knowledge I picked up in learning...other things that were necessary.
 
I understand the reason people keep using vim, but isn’t it easier with nano that also comes by default with entware?
I use a wide variety of Unix-like operating systems, and vi is always installed. I don't need to install Entware to use vi, it's in the firmware (it's possible nano may be as well, I've never looked). No matter what Unix-like OS I use, vi is there. Sure, vi doesn't have all the bells and whistles of vim, but usually getting stuff sorted and configured I don't need the fancy stuff anyways. Once stuff is sorted I can install vim. Since I'm a hobbyist, not an everyday user, I want to keep the number of programs I need to keep in my head to a minimum.
 
I use a wide variety of Unix-like operating systems, and vi is always installed. I don't need to install Entware to use vi, it's in the firmware (it's possible nano may be as well, I've never looked). No matter what Unix-like OS I use, vi is there. Sure, vi doesn't have all the bells and whistles of vim, but usually getting stuff sorted and configured I don't need the fancy stuff anyways. Once stuff is sorted I can install vim. Since I'm a hobbyist, not an everyday user, I want to keep the number of programs I need to keep in my head to a minimum.
nano is built in to the router, and pretty much any distro I've tried in the last couple of years :)
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top