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: 9,544
Thanks: 47
Thanked 5,084 Times in 2,154 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: 362
Thanks: 36
Thanked 249 Times in 128 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: 362
Thanks: 36
Thanked 249 Times in 128 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 08:19 AM.


Top 10 Stats
Top Posters* Top Thanked
RMerlin  341
sm00thpapa  232
stevech  185
azazel1024  148
KGB7  138
htismaqe  90
jim769  83
philmiami  77
AcostaJA  69
ColinTaylor  59
RMerlin  5083
stevech  315
ryzhov_al  249
TeHashX  209
RogerSC  187
L&LD  186
joegreat  123
jlake  122
sfx2000  111
sinshiva  111
Most Viewed Threads* Hottest Threads*
Old ASUS RT-N66U...  23812
Old NETGEAR...  12997
Old Switched...  7333
Old 3.0.0.4.376.1...  6746
Old NEW RT-AC68R...  6564
Old ASUS...  5964
Old ASUS RTAC68U...  3497
Old Netgear...  3288
Old ASUS...  3012
Old N66U daily...  2842
Old ASUS RT-N66U...  169
Old NETGEAR...  161
Old Switched...  64
Old NEW RT-AC68R...  56
Old ASUS...  55
Old N66U daily...  47
Old Which router...  41
Old ASUS RTAC68U...  41
Old Netgear...  41
Old ASUS...  38


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