What's new

URL to shutdown or other operations?

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

mmmmmm

Occasional Visitor
Hi,

I am thinking of writing a small widget for my Samsung Smart TV to shutdown/restart the router on request.
Giving the fact that the widget can only make some simple http requests I was wondering if there is a url on the rotuer's web server that will take some parameters and perform some actions.

Something like a basic webservice.

For instance my D-Link NAS can be switched off like so:

set UNAME=admin
set PASSWD=yourpassword
set IP=172.17.0.6

wget --tries=1 --timeout=5 "http://%IP%/goform/formLogin?f_login_type=0&f_LOGIN_NAME=%UNAME%&f_LOGIN_PASSWD=%PASSWD%"
IF %ERRORLEVEL%==0
(
wget --tries=1 --timeout=5 "http://%IP%/goform/sysShutDown?shootdown"
)
ELSE
(
echo Unable to shutdown NAS_002
)

NAS forum link: http://forums.dlink.com/index.php?topic=8362.0

Cand this be done on RT-n66U running Merlin's firmware?

Thank you.
 
That would be a nice gadget to samsung TV. I also have Samsung Smart TV so i'm interested of such gadget. Unfortunately i dont have enough knowledge to help You with this project, but i will keep cross my fingers :)
So good luck.
 
Thank you darius.

I think I am on to something.

Just found the "/Tools_RunCmd.asp" page that lets you execute linux commands from the web gui.

I think I am on the right track :).

I will post my findings.
 
maybe Merlin can give some pointers.

What data to post for login and for the system command?

Thanks in advance.
 
The web server uses basic HTTP authentication.
 
Thank you ryzhov_al for this valuable information.
It turns out that it's the same way here.

The request is the following:
h t t p://192.168.1.1/apply.cgi?current_page=Main_AdmStatus_Content.asp&next_page=Main_AdmStatus_Content.asp&next_host=&group_id=&modified=0&action_mode=+Refresh+&action_script=&action_wait=&first_time=&preferred_lang=EN&SystemCmd=df&action=Refresh

Now, I managed to execute simple command using this http request. So, simple shutdown seems to be possible in this way.

But I've noticed another interesting query string parameter: "action_script"

Now I am wondering if it's possible to execute a script (stored somewhere on the router: jfss or usb stick) that will first gracefully stop some daemons like transmission and then execute the shutdown.

Do you have any ideea if the mentioned parameter can be used for such scenario?
 
Last edited:
As long as you are on Asuswrt-Merlin, you may use /jffs/scripts/services-stop script:
# cat /jffs/scripts/services-stop
#!/bin/sh

logger -t $(basename $0) "started [$@]"

/opt/etc/init.d/rc.unslung stop

# SAMBA is holding files often
/usr/bin/killall smbd

When you run halt, Asuswrt-Merlin will execute this script before unmounting USB partition automagically.
 
When you run halt, Asuswrt-Merlin will execute this script before unmounting USB partition automagically.

Strange thing: I am requesting the page with sys_cmd=halt and it seems that the router does a reboot instead of a power down.

Also tried "halt -p -h".
I get the message "shutting down" int the "Tools_RunCmd.asp" page of the web gui, but the router (RT-N66U) reboots.

Am I missing someting?
Please advice.

Yes, I am using Merlin's version (3.0.0.4.246.20).
 
I've created the services-stop script on the jfss partition as you suggested and put some commands in there.

I've run "halt -p" (remotely via the apply.cgi http request) and I need to know if what happens is normal:

- the Power Led remains ON
- the WAN Led remains ON
- the USB Hdd connected to one of the USB is still powered on (2.5" hdd with a led on when connected to a device)

The Power button is of course On. Does this mean that the USBport will provide power to the usb devices?

What is the proper way to start the router after a software halt: press the power button to Off and then On, or is there another way?
 
I've run "halt -p" (remotely via the apply.cgi http request) and I need to know if what happens is normal:

- the Power Led remains ON
- the WAN Led remains ON
- the USB Hdd connected to one of the USB is still powered on (2.5" hdd with a led on when connected to a device)

The Power button is of course On. Does this mean that the USBport will provide power to the usb devices?
Yes, it's normal. It's not a big PC and it can't cut power from peripherals, it's a system on chip, we've got a soldered wire from power supply to USB connector:)) The halt make sense only for gracefully finish all jobs with USB-HDD.

What is the proper way to start the router after a software halt: press the power button to Off and then On, or is there another way?
Yes. In fact, halt finishes OS work and puts CPU to endless loop. Only hardware reset or off/on sequence can force router to boot again.
 
Yes, it's normal. It's not a big PC and it can't cut power from peripherals, it's a system on chip, we've got a soldered wire from power supply to USB connector:)) The halt make sense only for gracefully finish all jobs with USB-HDD.

I understand. It actually makes sense that as long as the power button is in On position, there will be power on the USB devices.

The question now is: does it makes any sense to "halt" the router since it will not actually switch it off completely?

I am using it as a small NAS (besinde my main one D-LINK DNS-343) and have the shares mounted on my Samsung TV. I was thinking, that when going to sleep, to switch off the router and the USB HDD from the TV.

I've tested the widget on the TV and it works, but I am not sure if it is very useful in this scenario. I think I will be better with only switching off the wireless and leave everything else up and running.

ryzhov_al, thank you very much for the time you spent to share your knowledge. I greatly appreciate it.
 
The question now is: does it makes any sense to "halt" the router since it will not actually switch it off completely?
I'm afraid no. Better to spin down HDD, you can save up to 3W, see below.
I've tested the widget on the TV and it works, but I am not sure if it is very useful in this scenario. I think I will be better with only switching off the wireless and leave everything else up and running..
Just FYI, I've measured RT-N66U's power consumption in different scenarios with this tool.
  • It's ~9 Watt regardless of CPU load or number of powered wireless interfaces.
  • It's ~12 Watt with 2.5" HDD attached.
 
Also tried "halt -p -h".
I get the message "shutting down" int the "Tools_RunCmd.asp" page of the web gui, but the router (RT-N66U) reboots.

Am I missing someting?
Please advice.

Yes, I am using Merlin's version (3.0.0.4.246.20).

There's isn't really a "power down" mode for the router. That wouldn't make much sense since the power switch is a mechanical toggle switch, so the router cannot be turned off through software.
 
There's isn't really a "power down" mode for the router. That wouldn't make much sense since the power switch is a mechanical toggle switch, so the router cannot be turned off through software.

I understand and it makes perfect sense.
Thank you so much for taking the time to share information.

I appreciate this useful forum and the great people taking time to share knowledge.
 
Just FYI, I've measured RT-N66U's power consumption in different scenarios with this tool.
  • It's ~9 Watt regardless of CPU load or number of powered wireless interfaces.
  • It's ~12 Watt with 2.5" HDD attached.

This is very useful info. Thank you very much.

As you suggested I've configured the router to spin down the drive and leave it on for now.
 
Similar threads

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