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, 11:05 AM
mmmmmm mmmmmm is offline
Member
 
Join Date: Nov 2012
Posts: 35
Thanks: 24
Thanked 3 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, 12: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, 12:48 PM
mmmmmm mmmmmm is offline
Member
 
Join Date: Nov 2012
Posts: 35
Thanks: 24
Thanked 3 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, 02:23 PM
mmmmmm mmmmmm is offline
Member
 
Join Date: Nov 2012
Posts: 35
Thanks: 24
Thanked 3 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, 07:11 PM
RMerlin's Avatar
RMerlin RMerlin is online now
Very Senior Member
 
Join Date: Apr 2012
Location: Canada
Posts: 10,760
Thanks: 55
Thanked 6,028 Times in 2,455 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, 02:11 AM
ryzhov_al's Avatar
ryzhov_al ryzhov_al is online now
Very Senior Member
 
Join Date: Jul 2012
Location: Smolensk, Russia
Posts: 403
Thanks: 46
Thanked 279 Times in 142 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 02:14 AM.
Reply With Quote
The Following User Says Thank You to ryzhov_al For This Useful Post:
  #7  
Old 01-12-2013, 05:14 AM
mmmmmm mmmmmm is offline
Member
 
Join Date: Nov 2012
Posts: 35
Thanks: 24
Thanked 3 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 05:16 AM.
Reply With Quote
  #8  
Old 01-12-2013, 05:48 AM
ryzhov_al's Avatar
ryzhov_al ryzhov_al is online now
Very Senior Member
 
Join Date: Jul 2012
Location: Smolensk, Russia
Posts: 403
Thanks: 46
Thanked 279 Times in 142 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, 06:15 AM
mmmmmm mmmmmm is offline
Member
 
Join Date: Nov 2012
Posts: 35
Thanks: 24
Thanked 3 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, 06:15 AM
mmmmmm mmmmmm is offline
Member
 
Join Date: Nov 2012
Posts: 35
Thanks: 24
Thanked 3 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 10:41 AM.


Top 10 Stats
Top Posters* Top Thanked
RMerlin  365
john9527  150
azazel1024  119
stevech  114
htismaqe  103
sfx2000  78
L&LD  76
TonyH  68
AndreyPopov  53
ColinTaylor  52
RMerlin  6027
john9527  377
stevech  350
ryzhov_al  279
TeHashX  233
L&LD  232
RogerSC  199
sinshiva  147
sfx2000  133
joegreat  126
Most Viewed Threads* Hottest Threads*
Old Shellshock...  27638
Old Asuswrt-Merli...  14512
Old Brainstorming...  2302
Old Looking for...  2082
Old RT-AC68P  2065
Old Advice on...  1919
Old RT-AC68U...  1480
Old Asus...  1454
Old Issues...  1379
Old AC-68...  1322
Old Asuswrt-Merli...  118
Old Advice on...  48
Old Brainstorming...  47
Old Looking for...  35
Old Shellshock...  31
Old Stable...  25
Old Issues...  25
Old WiFi Rates  23
Old RT-AC68U...  22
Old Belkin Pre-N...  21


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