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 offline
Very Senior Member
 
Join Date: Apr 2012
Location: Canada
Posts: 10,021
Thanks: 54
Thanked 5,527 Times in 2,272 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 offline
Very Senior Member
 
Join Date: Jul 2012
Location: Smolensk, Russia
Posts: 376
Thanks: 39
Thanked 265 Times in 136 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 offline
Very Senior Member
 
Join Date: Jul 2012
Location: Smolensk, Russia
Posts: 376
Thanks: 39
Thanked 265 Times in 136 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 03:30 AM.


Top 10 Stats
Top Posters* Top Thanked
RMerlin  477
azazel1024  155
stevech  138
KGB7  129
sinshiva  113
Kel-L  91
hggomes  90
fistv  85
sm00thpapa  81
sfx2000  78
RMerlin  5526
stevech  322
ryzhov_al  265
TeHashX  215
RogerSC  188
L&LD  188
sinshiva  140
joegreat  123
jlake  122
sfx2000  118
Most Viewed Threads* Hottest Threads*
Old Asuswrt-Merli...  74142
Old Asuswrt-Merli...  58709
Old Asuswrt-Merli...  24184
Old Asus locking...  9144
Old [Fork]...  9048
Old ASUS...  6967
Old Incoming...  6083
Old Asus...  5332
Old Share What...  3057
Old Download...  2899
Old Asuswrt-Merli...  392
Old Asuswrt-Merli...  389
Old Asuswrt-Merli...  133
Old Asus locking...  125
Old [Fork]...  88
Old Asus...  52
Old ASUS...  49
Old Inherited PC...  45
Old 376.44 -...  40
Old Connection...  39


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