Help With Custom Scripts

  • ATTENTION! As of November 1, 2020, you are not able to reply to threads 6 months after the thread is opened if there are more than 500 posts in the thread.
    Threads will not be locked, so posts may still be edited by their authors.
    Just start a new thread on the topic to post if you get an error message when trying to reply to a thread.

Kim Puleston

Regular Contributor
Hello all,

I am breaking into the world of custom scripts for my Asus Router AC88U. Now reading some of the Tutorials on how to setup various functions such as Adblock make sense but for one part, actually adding the scripts to particular directories in JFFS.

For example I may get asked to place a script in ''Wan-Start'' but how do I do that via an SSH terminal ? Do I need to browse to that directory before inputing a script ?

As below

''
Virtual Interface
Next we create a virtual interface with 192.168.1.3. This need to be performed on every boot (or more precisely every time the WAN interface comes up). Hence, append the following two lines to your /jffs/scripts/wan-start:

ifconfig br0:pixelserv 192.168.1.3 up
logger -t $(basename $0) "br0:pixelserv 192.168.1.3 created."
''
Exactly what commands within SSH do I need to use in order to browse to specific directories on the router ?

Thanks all.
 

john9527

Part of the Furniture
What you are really asking is 'How do I use linux?' Best bet is to do a web search on 'Linux basic commands' and start reading :)

The built in editor is called vi, and starting with 380.62 Nano editor is also included. More searches and reading.....
 

Kim Puleston

Regular Contributor
I figured it would be a case of that. When you say the built in editor...is that I am using when I am using Putty to SSH into the router ?

I have been using Putty to access the router all this time, is there another way I should be going about this ?

Sorry for the Ignorance.
 
Last edited:

dvohwinkel

Senior Member
I figured it would be a case of that. When you say the built in editor...is that I am using when I am using Putty to SSH into the router ?

I have been using Putty to access the router all this time, is there another way I should be going about this ?

Sorry for the Ignorance.

No when you use putty to ssh into the router you are put in a shell(kind of like a command prompt in Windows) and from there you can execute the built in editor nano or vi.
 

Kim Puleston

Regular Contributor
Thanks guys, big help. I will have to look up the command when in SSH to invoke one of the editors or give Winscp a go.
 

RMerlin

Asuswrt-Merlin dev
Thanks guys, big help. I will have to look up the command when in SSH to invoke one of the editors or give Winscp a go.

The basics for script editing. Once connected over SSH:

Code:
nano -w /jffs/scripts/whatever-script

While editing, to save the file:

Code:
Ctrl-O

it will ask you to confirm the filename, press enter to keep the existing filename.

To exit from nano:

Code:
Ctrl-X

Remember that all scripts (NOT config files) must begin with a shebang. The first line must be:

Code:
#/bin/sh

This tells Linux how to execute the script (in this case, it's a shell script, so it runs through "sh". A Perl script would have "perl" in that line, for example).
 

Kim Puleston

Regular Contributor
Thanks guys. WinSCP seems like a good one. Just out of interest I notice I can open txt files in WinSCP, edit them and then save them. Is it ok to do this with existing plain txt files and use Notepad++ to create new files ?
 

ColinTaylor

Part of the Furniture
Thanks guys. WinSCP seems like a good one. Just out of interest I notice I can open txt files in WinSCP, edit them and then save them. Is it ok to do this with existing plain txt files and use Notepad++ to create new files ?
You can use either editor for both tasks. WinSCP comes with a built-in edit which is just fine. Notepad++ is a separate product with more features which integrates well with WinSCP. The choice is yours.
 

thelonelycoder

Part of the Furniture
Now reading some of the Tutorials on how to setup various functions such as Adblock make sense but for one part, actually adding the scripts to particular directories in JFFS.
I'll just drop this line here.
There's an easy and a hard(er) way to add ad blocking to your router...
 

L&LD

Part of the Furniture
I'll just drop this line here.
There's an easy and a hard(er) way to add ad blocking to your router...

Yes! AB-Solution by thelonelycoder is the easy way. :)

The OP wants to learn to script though. ;)

Must be nice to have time on his hands. :D
 

thelonelycoder

Part of the Furniture
Must be nice to have time on his hands.
If I hadn't started this all, I would actually have time to learn coding and play with Unix stuff...
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

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