SmallNetBuilder Forums
Go Back   SmallNetBuilder Forums > Wireless Networking > ASUS Wireless > Asuswrt-Merlin

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-11-2013, 12:05 PM
mmmmmm mmmmmm is offline
Member
 
Join Date: Nov 2012
Posts: 35
Thanks: 24
Thanked 4 Times in 2 Posts
mmmmmm is just starting out
Default URL to shutdown or other operations?

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_LO GIN_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.
Reply With Quote
  #2  
Old 01-11-2013, 01:45 PM
darius456 darius456 is offline
New Member
 
Join Date: Oct 2012
Posts: 11
Thanks: 0
Thanked 1 Time in 1 Post
darius456 is just starting out
Default

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.
Reply With Quote
  #3  
Old 01-11-2013, 01:48 PM
mmmmmm mmmmmm is offline
Member
 
Join Date: Nov 2012
Posts: 35
Thanks: 24
Thanked 4 Times in 2 Posts
mmmmmm is just starting out
Smile

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.
Reply With Quote
  #4  
Old 01-11-2013, 03:23 PM
mmmmmm mmmmmm is offline
Member
 
Join Date: Nov 2012
Posts: 35
Thanks: 24
Thanked 4 Times in 2 Posts
mmmmmm is just starting out
Default

maybe Merlin can give some pointers.

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

Thanks in advance.
Reply With Quote
  #5  
Old 01-11-2013, 08:11 PM
RMerlin's Avatar
RMerlin RMerlin is offline
Very Senior Member
 
Join Date: Apr 2012
Location: Canada
Posts: 11,489
Thanks: 61
Thanked 6,393 Times in 2,628 Posts
RMerlin is just starting out
Default

The web server uses basic HTTP authentication.
__________________
Asuswrt-Merlin: Customized firmware for Asus routers
Github: github.com/RMerl - Twitter: RMerlinDev
See the sticky post for more info.
Reply With Quote
The Following User Says Thank You to RMerlin For This Useful Post:
  #6  
Old 01-12-2013, 03:11 AM
ryzhov_al's Avatar
ryzhov_al ryzhov_al is offline
Very Senior Member
 
Join Date: Jul 2012
Location: Smolensk, Russia
Posts: 429
Thanks: 49
Thanked 298 Times in 149 Posts
ryzhov_al is just starting out
Default

Quote:
Originally Posted by RMerlin View Post
The web server uses basic HTTP authentication.
We ran some commands on Oleg's firmware this way before:
Quote:
$ wget --user=admin --password=P@ssword "http://192.168.1.1/apply.cgi?current_page=syscmd_out.asp&action_mode= +Refresh+&SystemCmd=halt"
mmmmmm is quite close to solution)
__________________
The Entware. A modern Optware replacement.

Last edited by ryzhov_al; 01-12-2013 at 03:14 AM.
Reply With Quote
The Following User Says Thank You to ryzhov_al For This Useful Post:
  #7  
Old 01-12-2013, 06:14 AM
mmmmmm mmmmmm is offline
Member
 
Join Date: Nov 2012
Posts: 35
Thanks: 24
Thanked 4 Times in 2 Posts
mmmmmm is just starting out
Default

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=&gr oup_id=&modified=0&action_mode=+Refresh+&action_sc ript=&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 by mmmmmm; 01-12-2013 at 06:16 AM.
Reply With Quote
  #8  
Old 01-12-2013, 06:48 AM
ryzhov_al's Avatar
ryzhov_al ryzhov_al is offline
Very Senior Member
 
Join Date: Jul 2012
Location: Smolensk, Russia
Posts: 429
Thanks: 49
Thanked 298 Times in 149 Posts
ryzhov_al is just starting out
Default

As long as you are on Asuswrt-Merlin, you may use /jffs/scripts/services-stop script:
Quote:
# 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.
__________________
The Entware. A modern Optware replacement.
Reply With Quote
  #9  
Old 01-12-2013, 07:15 AM
mmmmmm mmmmmm is offline
Member
 
Join Date: Nov 2012
Posts: 35
Thanks: 24
Thanked 4 Times in 2 Posts
mmmmmm is just starting out
Default

Quote:
Originally Posted by ryzhov_al View Post
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).
Reply With Quote
  #10  
Old 01-12-2013, 07:15 AM
mmmmmm mmmmmm is offline
Member
 
Join Date: Nov 2012
Posts: 35
Thanks: 24
Thanked 4 Times in 2 Posts
mmmmmm is just starting out
Default

Quote:
Originally Posted by ryzhov_al View Post
As long as you are on Asuswrt-Merlin, you may use /jffs/scripts/services-stop
Awesome. Thank you very much for this information. Very very useful.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 06:30 AM.


Top 10 Stats
Top Posters* Top Thanked
RMerlin  366
L&LD  123
john9527  116
htismaqe  98
azazel1024  94
stevech  86
jegesq  77
huotg01  75
watusi  54
ColinTaylor  53
RMerlin  6392
john9527  502
stevech  357
ryzhov_al  298
TeHashX  263
L&LD  255
RogerSC  205
sinshiva  149
sfx2000  137
joegreat  128
Most Viewed Threads* Hottest Threads*
Old New AC68...  9392
Old Why not...  8097
Old ASUS RT-N66U...  5572
Old RT-AC66U...  3387
Old Why ASUS?  2355
Old Linksys...  2152
Old NAS...  1821
Old Help Plz:...  1593
Old Asus...  1491
Old OpenVPN...  1394
Old Why not...  81
Old Remote...  45
Old New AC68...  36
Old Extension...  26
Old The future...  26
Old RT-N66U...  25
Old Whats going...  24
Old OpenVPN...  24
Old What are the...  24
Old ASUS RT-N66U...  24


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2006-2014 Pudai LLC All Rights Reserved.