Create scripts not using the command box in gui

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
eugene1973
DD-WRT User


Joined: 21 May 2017
Posts: 186

PostPosted: Sun Oct 20, 2019 21:47    Post subject: Create scripts not using the command box in gui Reply with quote
I want to know how I can safely create a
script not using the command box in the
gui for dd-wrt. I'm doing this because
I have another router that does not use
dd-wrt. It uses BusyBox. It's all the
same. There are articles on the net but
I want to take the simplest approach
that works on all Linux.

I'm only using the following

nvram set ....
nvram unset ...

I can just use set without nvram
statement. unset as well.

I'm also using ifconfig ....

It should be a simple method that
will accept common input to manipulate
the box.

I don't need anything else.

This is just like using the command
box but only OS prompt input is needed.

How to create the files and how and
where to put them is also needed.
Sponsor
Wildlion
DD-WRT Guru


Joined: 24 May 2016
Posts: 1416

PostPosted: Mon Oct 21, 2019 0:54    Post subject: Reply with quote
a script is a script on all linux machines, including dd-wrt.

More than likely the shell is different, but if you use busybox they all should have sh, now whether that is simlinked or you have to call busybox sh is different

but an example would be:
Code:

#!/bin/sh

echo Hello World


you just need the #!/bin/sh at the top to specify the shell to use.

Then make it executable via chmod
and it can be placed where ever as long as that area is allowed to execute files (some mount options restrict this)
then make sure that it executed by whatever mechanism you want.

for example ./Hello_world
eugene1973
DD-WRT User


Joined: 21 May 2017
Posts: 186

PostPosted: Mon Oct 21, 2019 3:01    Post subject: Reply with quote
I have read various articles and have
come to some conclusions. I want step
by step examples.

Please help. I'm listening either way
though.

I will give my busybox directory output
soon.
Wildlion
DD-WRT Guru


Joined: 24 May 2016
Posts: 1416

PostPosted: Tue Oct 22, 2019 22:35    Post subject: Reply with quote
how step by step?

In the example I did:
Code:

root@DDWRTNet:~# pwd
/tmp/root
root@DDWRTNet:~# vi Hello_world
root@DDWRTNet:~# chmod a+x Hello_world
root@DDWRTNet:~# ls
Hello_world
root@DDWRTNet:~# ./Hello_world
Hello World


You saw the script before
eugene1973
DD-WRT User


Joined: 21 May 2017
Posts: 186

PostPosted: Thu Oct 24, 2019 5:21    Post subject: Reply with quote
Great reply Wildlion. Kudos!!!!👍

Here is my BusyBox output.

I have a couple more questions.



BusyBox v1.10.3 (2015-02-03 14:37:55 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.


quantenna # cd /
quantenna # ls
bin init mnt root tmp
dev lib opt sbin usr
etc linuxrc proc scripts var
home log.txt release.txt sys www
quantenna # pwd
/

quantenna # type -p sh
/bin/sh



I wonder where I should put the script file?

root ?

Shouldn't it be next to rc.local asthetically?

Also I want it to run after all other input
at startup, that means I need to find out
the number of items first. How?

Doesn't that mean changing chmod?

Will the chmod a+x already do that?

I gave my directory listing. Can someone
Give step by step with this info as the
script input...

ip -6 addr add 2001::0 dev br0

Thx.

Tell me how this will be exactly.
I plan to just insert other lines
under that ip line I gave.
Wildlion
DD-WRT Guru


Joined: 24 May 2016
Posts: 1416

PostPosted: Thu Oct 24, 2019 22:04    Post subject: Reply with quote
For DDWRT it seems like you want to read something like these:

https://wiki.dd-wrt.com/wiki/index.php/Index:Scripting

possibly specifically this for startup:
https://wiki.dd-wrt.com/wiki/index.php/Startup_Scripts#Shell_Script_Method


The majority is the same, but there are slight differences from a normal GNU/linux system.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking 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 cannot attach files in this forum
You cannot download files in this forum