What's new

Noob Scripting question

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

PoppinJ

Occasional Visitor
Ive been googling like crazy trying to figure this out but Ive never used any scripts before so I'm totally lost. I have "Enable JFFS custom scripts and configs" in the router and expected that to create a"cmd" tab in administration where I paste the script Im trying to run but apparently thats not the case. I am trying to add this script for plex to WOL

https://www.reddit.com/r/PleX/comments/35xw5t/how_to_set_your_computer_to_sleep_and_wake_on_an

Ive read these guides and many others but Im just lost.
https://github.com/RMerl/asuswrt-merlin/wiki/User-scripts
http://www.dd-wrt.com/wiki/index.php/Script_Execution

Best I can tell I have to create a specific folder in the usb drive on the router and the create a .txt document, copy paste the script Im trying to create and save it under a specific name with a specific extension. Im just so thrown off.

Do I simply create a "jffs" folder with a subfolder "scripts" on the usb drive and place the .txt document inside it? Sorry for these stupid questions but Im trying to learn.
 
No responses so Im still trying to figure this out on my own. Its looking like I need to enable SSH login and use putty from windows to get into the routers jffs?

Is what Im looking for a startup script? I was really expecting there to be a command tab once I enabled jffs and custom scripts, but since that didnt happen Im guessing this is what I need to do?
http://www.dd-wrt.com/wiki/index.php/Startup_Scripts
 
Read all of this: https://github.com/RMerl/asuswrt-merlin/wiki

Honestly, you are so new to all this that I would say slowww down. Trying to learn all this stuff too quickly can get you in trouble. Some unix experience is encouraged.

We are happy to help, but you must show us that you have learned (or tried to learn) most of the FAQ/wiki information.

Hint: The page I linked explains how to setup jffs. Usually you just select an "Enable JFFS" radio-button along with maybe a "Format JFFS on restart" radio-button & restart.
 
I have a closely related question, which I think makes sense to post here, rather than start a new thread.

I too would like to learn more about scripts. I have read the documentation very thoroughly (including the wiki referred to above), and follow the postings on the forum carefully. However I am not exactly clear on how to get the script into the right place on the router.

It seems to me that a good way would be as follows:
1-Mount a USB stick in the router, and map to it in Windows
2-Write a script on the USB stick, using a text editor I am familiar with (in mycase TextPad), making sure to save the script in Unix format
3-Use Putty to SSH into the router, and copy the script from the USB stick to the /jffs/scripts directory on the router
cp /mnt/myusb/myscript.sh /jffs/scripts
4-Use chmod to set the appropriate permissions for the script in its new location.
chmod a+rx /jffs/scripts/myscript.sh

Am I on the right lines here please ? Is there an easier way ? The USB stick is formatted FAT32 so that I can also use it directly on my PC, but I think this should not matter.

I could probably write the script directly in place using the built-in editor, but I would prefer to use an editor I am already familiar with, and then simply copy the script to the correct location.

I am very familiar with Windows, but new to Unix. In Windows, when copying a file to a new directory, the copy automatically inherits the permissions of the destination directory. Does the same apply here? So, if chmod is used to set the permissions for the jffs/scripts directory, do all files copied to there automatically inherit the permissions of the directory? Or is it necessary to use chmod every time a new script is copied to the jffs/scripts directory?

While I am here I would like to say how much I appreciate the excellent work done by RMerlin, and the very helpful advice given by the regular contributors to the forum, who are willing to share their expertise with newcomers like myself. It is very much appreciated.

best regards, PB
 
Thanks so much guys, especially Zirescu for the link to the tutorial. I now understand that I was pretty much asking, "hey somebody teach me linux real quick" Ive got it working great now so thanks. One question though, how do I get it to listen to two ports instead of one. Right now it's
#!/bin/sh

INTERVAL=5
NUMP=3
OLD=""
TARGET=PUT YOUR INTERNAL IP ADRESS HERE!
PORT=SPECIFY YOUR PORT HERE!
IFACE=br0
MAC=PUT YOUR MAC ADRESS HERE!
WOL=/usr/bin/ether-wake
LOGFILE="/var/log/ether-wake.log"

...
How do you specify two separate ports?

PolarBear, you sound like you are confused about the same things I was. I knew what needed to happen just not how to create the files and get them where they needed to be. Plus I thought everything had to be done strictly through the command line. Forget the USB drive, that's not where the files go, at least not the jffs/scripts files. Once you enable everything in the administration tab you need to use WINSCP to access the router and create the text files (scripts) in the correct directory, then SSH back into the router to use the chmod commands.
 
Last edited:
Once you enable everything in the administration tab you need to use WINSCP to access the router and create the text files (scripts) in the correct directory, then SSH back into the router to use the chmod commands.

Actually ....you don't have to SSH and manually run the chmod command. To save time, having used WinSCP to create the script directly on the router, you can set the execute permissions of the script whilst still in WinSCP by simply right-clicking the file and select 'Properties' and put a tick mark in the appropriate 'X' execute box.

Furthermore, you may also execute the script from within WinSCP by right-clicking it, then selecting 'Custom Commands' then 'Execute'. However, I usually click the WinSCP 'Commands' pull-down menu and select 'Open in PuTTY' (assuming you have Putty configured in WinSCP) to manually execute the scripts if WinSCP complains about a nonzero a failure code!
 
Last edited:
you need to use WINSCP to access the router and create the text files (scripts) in the correct directory, then SSH back into the router to use the chmod commands.

Thanks PoppinJ, that cuts out a couple of steps and sounds like a good tip.

WINSCP is downloading right now, and I will test it out tomorrow.
 

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