What's new

Scripts

  • 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!

TheLyppardMan

Very Senior Member
I know there is a script for turning the leds off and on at scheduled times, but for a total newbie to scripts, could someone tell me exactly where to put the scripts in the GUI (if that's where they go). I would need precise step-by-step instructions please.
 
Have a look under Tools => other settings => Miscellaneous Options => Stealth Mode (disable all LEDs)
 
Last edited:
Have a look under Tools => other settings => Miscellaneous Options => Stealth Mode (disable all LEDs)
Yes, I had already found that, but what I want to do is use the script schedule to turn the leds on and off at certain times. What I don't know is where exactly the scripts go.
 
/jffs/scripts/services-start
Code:
#!/bin/sh
cru a lightsoff "0 18 * * * /jffs/scripts/ledsoff.sh"
cru a lightson "0 6 * * * /jffs/scripts/ledson.sh"
For lights off at 18:00, that's 6 pm and on at 6 am.

/jffs/scripts/ledsoff.sh
Code:
#!/bin/sh
nvram set led_disable=1
nvram commit
service restart_leds

/jffs/scripts/ledson.sh
Code:
#!/bin/sh
nvram set led_disable=0
nvram commit
service restart_leds
 
/jffs/scripts/services-start
Code:
#!/bin/sh
cru a lightsoff "0 18 * * * /jffs/scripts/ledsoff.sh"
cru a lightson "0 6 * * * /jffs/scripts/ledson.sh"
For lights off at 18:00, that's 6 pm and on at 6 am.

/jffs/scripts/ledsoff.sh
Code:
#!/bin/sh
nvram set led_disable=1
nvram commit
service restart_leds

/jffs/scripts/ledson.sh
Code:
#!/bin/sh
nvram set led_disable=0
nvram commit
service restart_leds

Can you post a screenshot, showing exactly where to put these in the GUI? Thanks.
 
There is no GUI for that, these are scripts that go where the wiki article mentioned above says they go.
 
There is no GUI for that, these are scripts that go where the wiki article mentioned above says they go.
It's probably so obvious to you are you've probably done this sort of things loads of times, but to a newbie like me to simply say "scripts that go where the wiki article mentioned above says they go" means nothing to me. I can see something that says "/jffs/scripts/services-start" but what is that? Unless someone can give me step-by-step instructions to get me started on this, I might just as well give up.
 
It's probably so obvious to you are you've probably done this sort of things loads of times, but to a newbie like me to simply say "scripts that go where the wiki article mentioned above says they go" means nothing to me. I can see something that says "/jffs/scripts/services-start" but what is that? Unless someone can give me step-by-step instructions to get me started on this, I might just as well give up.

Been there. Maybe this similar thread post will get you going:

http://www.snbforums.com/threads/scheduling-rebooting.11044/#post-68429
 
It's probably so obvious to you are you've probably done this sort of things loads of times, but to a newbie like me to simply say "scripts that go where the wiki article mentioned above says they go" means nothing to me. I can see something that says "/jffs/scripts/services-start" but what is that? Unless someone can give me step-by-step instructions to get me started on this, I might just as well give up.


I think we're back to the topic of the other day where I gave you full marks for bravery

http://www.snbforums.com/threads/2-questions-1-stealth-mode-and-2-updates.30894/#post-244597

And Merlin said forget Putty, use XShell instead. . However, given my very limited knowledge on scripts, I believe that your easiest route is to install WinSCP and get it working so you can connect to the router with it. (Use the SCP protocol as Colin says here http://www.snbforums.com/threads/ip-tables-confusion.30373/#post-237550.). WinSCP will allow you to create Linux/Unix folders/directories etc all from the comfort of the Windows desktop. I think you have to create the services-start folder and put the script file into it. To edit or create the script file, in Windows, you need something like Notepad++ set to Unix formatting (see the topic in the first link)

I've used WinSCP and SSH plenty of times, but never done scripts, so I'm keen to know how it goes; you should be a lot higher up the learning curve than I am by the end of it. Good luck.
 
I think you have to create the services-start folder and put the script file into it.
No, the name of the script is services-start and it goes in the /jffs/scripts directory.
To edit or create the script file, in Windows, you need something like Notepad++ set to Unix formatting (see the topic in the first link)
It's not necessary to have Notepad++ if you have WinSCP because it has its own built-in editor. Just right-click in the directory and choose New>File, just like Windows explorer. (If you already have Notepad++ installed WinSCP can be configured to use it in preference to its own editor.)
 
OK, I have xShell5 and WinSCP installed. Which do I need to use to add the script to turn on/off the led's? After finding out that I needed to enable SSH, I managed to log in to my router using WinSCP. I have uploaded a screenshot showing what I can see in the right-hand pane of WinSCP after logging in to my router. What's the next step?
 

Attachments

  • Screenshot - 17_03_2016 , 12_42_30.jpg
    Screenshot - 17_03_2016 , 12_42_30.jpg
    23 KB · Views: 570
You are in the directory /tmp/home.

Double-click the two dots (..) to go up one level. Then do the same again and you will be in the root directory (/).

From there you should see the jffs directory. Double-click it. Within there should be a scripts directory. Double-click it.

You should now be in /jffs/scripts.

Right-click in that window and choose New->File.

Update: After saving your file and exiting the editor, right-click on the file and select Properties. Under Permissions tick all the R, W and X boxes. Leave the other 3 boxes clear. Then click OK.
 
Last edited:
OK, I've found the jffs/scripts directory. What do I call the file and what do I put in it?
 
See post #5.

You want 3 scripts. One called services-start, one called ledsoff.sh and another called ledson.sh
 
OK, I've created the files and copied/pasted the scripts in from post number 5. I've also set the permissions as described above and amended the off time to 0 22 for lights off. Will I need to reboot the router before they will take effect (if so, I'll have to do it tomorrow, when everyone is out)? Also, what would I use for midnight, 0 or 24?
 
OK, I've created the files and copied/pasted the scripts in from post number 5. I've also set the permissions as described above and amended the off time to 0 22 for lights off. Will I need to reboot the router before they will take effect (if so, I'll have to do it tomorrow, when everyone is out)? Also, what would I use for midnight, 0 or 24?

I'm well impressed. Think I'll try it myself just for my first experience of writing a script.

Yes, I believe you have to reboot the router for your script to take effect.

And from https://en.m.wikipedia.org/wiki/Cron#Format
I understand that you would enter 0 rather than 24 for midnight. You could always elect for 23:59 as an exercise in correctly inserting the hours and minutes format :)
 
martinr is correct, you need to reboot the router. There are other ways of activating it but rebooting the router is easiest. ;)

martinr is also correct in saying that midnight is hour 0 not 24.
 
Well, I'm pleased to report that it works, so thanks to everyone who walked me through this process. As they say, it's easy when you know how!
 

Similar threads

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