What's new

start up script ?

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

dryasanne

Occasional Visitor
I need to run a script every hour on my asus rt-n66u, this one:

-----------

cru a IPUpdate "*/60 * * * * root wget http://www.unotelly.com/unodns/auto_auth/hash_update/updateip.php?user_hash=your_token"


-------------

Under tools, I can send this as a command. But how and where do I enter this script so the router will do this every hour (without me entering it manually)?

I dont know much about that scripting, please explain with simple words :)
 
Really? I am linux noob but it is really well laid out by RMerlin, just follow up the steps.

Quote github:

"Note however that this will cause additional wear on your flash, and might slightly shorten its life, as the flash RAM has a limited possible amount of write cycles. "


If my script will shorten my router working life, I dont want to use this script ;.(
 
If my script will shorten my router working life, I dont want to use this script ;.(

This is the case only if you or your script writes something there. If you slightly change your script e.g. in a way that wget stores the output to some external attached to USB port - it's not an issue any more.
 
This is the case only if you or your script writes something there. If you slightly change your script e.g. in a way that wget stores the output to some external attached to USB port - it's not an issue any more.


Aaah?

So when I upload my script, it is only read by the router, nothing is written then??

The script is meant to a one time, not to be changed.


So this may be not hurt my router anyway ?
 
Writing a script once or twice won't have any measurable impact on the flash durability.

Writing a log file every 5 mins to that same flash - that is a sure way to make it suffer from a premature death.

This is kinda similar to SSDs, where each cell has a fixed number of possible flashes before they "burn out". The flash probably has a durability of a few thousand times (no idea on actual number).
 
Writing a script once or twice won't have any measurable impact on the flash durability.

Exactly, but:

So when I upload my script, it is only read by the router, nothing is written then??

That depends on the script and as far as I understand yours, wget is fetching some data from www.unotelly.com and stores it somewhere (current working directory?) - if you redirect this to external drive, you won't write anything to the router.
 
Exactly, but:



That depends on the script and as far as I understand yours, wget is fetching some data from www.unotelly.com and stores it somewhere (current working directory?) - if you redirect this to external drive, you won't write anything to the router.

Mea Culpa.

You know, I feel old :-(
I had to turn everything OFF. I had to walk the long walk to my Rega turntable. I put on a LP. Traweling Wilburys vol one.

Of course, that script now is in the flash, now I get it displayed in my command window of asus, typing cru list, oh yes, it is stored properly no problem.

I forgot that last quotation mark. And I didnt understand MY script is named IPUpdate.

So. How do I now test that this script really works. Need to listen to volume three to grasp that one.
 
Last edited:
Exactly, but:



That depends on the script and as far as I understand yours, wget is fetching some data from www.unotelly.com and stores it somewhere (current working directory?) - if you redirect this to external drive, you won't write anything to the router.

Correct. In his case, he could simply redirect the output to the ram disk (/tmp).
 
Please excuse the very basic nature of this question. I follow how to use RMerlin guide on creating a schedule using Telnet.

My question is using scripts that have already been created using Notepad++ that are saved with unix encoding on the desktop. For example, a port forwarding script named firewall-start.

The readme states to save these scripts into the jffs/scripts partition. How exactly do I do that? The jffs has been created and formatted. Just unsure of copy syntax to copy from desktop into the scripts folder.

Secondly, the script has been saved on the desktop as firewall-start.sh Do I leave the .sh on the end or remove it?

Thank you for your help.
 
Please excuse the very basic nature of this question. I follow how to use RMerlin guide on creating a schedule using Telnet.

My question is using scripts that have already been created using Notepad++ that are saved with unix encoding on the desktop. For example, a port forwarding script named firewall-start.

The readme states to save these scripts into the jffs/scripts partition. How exactly do I do that? The jffs has been created and formatted. Just unsure of copy syntax to copy from desktop into the scripts folder.

Secondly, the script has been saved on the desktop as firewall-start.sh Do I leave the .sh on the end or remove it?

Thank you for your help.

I find it much easier to create files in telnet using echo command. I will create it in notepad and then "cut and paste" into telnet window. Example below is startup script I created. Everything between ' and ' is put into the file with the first echo creating the file and each additional echo appending a line to that file. Here's an example:

echo '#!/bin/sh' >> /jffs/scripts/services-start
echo 'killall dnsmasq' >> /jffs/scripts/services-start
echo 'dnsmasq -c 1500 --log-async -n' >> /jffs/scripts/services-start
echo 'touch /tmp/000dnsmasqstarted' >> /jffs/scripts/services-start

Then to make sure it's executable telnet a command with the syntax below (substituting location / name of your file)

chmod +x /jffs/scripts/services-start
 
Last edited:
Assuming you are using Windows, enable SSH into the router.

Download WinSCP and create an 'SCP' connection to the router SSH port.

You will see two window panes so you can simply drag and drop from the Windows source directory on the left (where you created the notepad++ file) into the /jffs/scripts directory on the right...

PF9 lets you set the 'execute' 777 attribute on the /jffs/scripts file, and if you right click the file and select custom commnads, you should be able to click 'execute'

No need to physically telnet/SSH into a command prompt on the router - unless you need to!

Regards,
 
Last edited:
rayik and Martineau,

Thank you for your prompt response. The commands I was using at Telnet would vanish upon reboot. With the knowledge you have given, I think I now understand how to place in the scripts folder for permanence.
Update: WinSCP works beautifully. I can now see folders and scripts created using echo on telnet & drag and drop from scripts on Windows desktop. Bonus- files can be edited easily as well. Again, many thanks to all.
 
Last edited:
echo '#!/bin/sh' >> /jffs/scripts/services-start
echo 'killall dnsmasq' >> /jffs/scripts/services-start
echo 'dnsmasq -c 1500 --log-async -n' >> /jffs/scripts/services-start
echo 'touch /tmp/000dnsmasqstarted' >> /jffs/scripts/services-start

Just a nit: the first line ought to have only one > in it. If the file existed previously, you want to make sure the first echo command creates a new file.
 
Just a nit: the first line ought to have only one > in it. If the file existed previously, you want to make sure the first echo command creates a new file.

Okay, so it's just like the redirect symbol in a Windows command prompt?

> = overwrite existing file with this line (creates new file if it doesn't exist).
>> = append existing file with this line (creates new file if it doesn't exist).

In Windows, either a single or double ">" will create a new file if it didn't exist before.

From the prior posts it appears I can assume the echo command does the same as in Windows. Correct?
 
Assuming you are using Windows, enable SSH into the router.

Download WinSCP and create an 'SCP' connection to the router SSH port.

You will see two window panes so you can simply drag and drop from the Windows source directory on the left (where you created the notepad++ file) into the /jffs/scripts directory on the right...

PF9 lets you set the 'execute' 777 attribute on the /jffs/scripts file, and if you right click the file and select custom commnads, you should be able to click 'execute'

No need to physically telnet/SSH into a command prompt on the router - unless you need to!

Regards,


Hallo Merlin, after a Firemware Update 270 to 374 all my Scripts in JFFS are deletet. Wy it this so???
Now i will copy with WinSCp but i have a Error.
"scp: /jffs/nat-start: Read-only file system"
What ist wrong.

Greeting Horst
 
Hallo Merlin, after a Firemware Update 270 to 374 all my Scripts in JFFS are deletet. Wy it this so???
Because "…This space will survive reboot (but it might NOT survive firmware flashing, so back it up first before flashing!)."

The reason is a flash layout: JFFS uses free space left in flash, which is not occupied by firmware. When firmware length changes after update, JFFS has to be relocated too, which mean it's old content will be lost.

Now i will copy with WinSCp but i have a Error.
"scp: /jffs/nat-start: Read-only file system"
What ist wrong.
You have to re-enable JFFS again and reformat it on next boot.
 

Similar threads

Sign Up For SNBForums Daily Digest

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