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: 8,453
Thanks: 43
Thanked 4,368 Times in 1,871 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: 296
Thanks: 23
Thanked 199 Times in 106 Posts
ryzhov_al is just starting out
Send a message via ICQ to ryzhov_al Send a message via Skype™ to ryzhov_al
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: 296
Thanks: 23
Thanked 199 Times in 106 Posts
ryzhov_al is just starting out
Send a message via ICQ to ryzhov_al Send a message via Skype™ to ryzhov_al
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 09:04 AM.

Top 10 Stats
Top Posters* Top Thanked
RMerlin  315
L&LD  159
thelonelycode...  144
stevech  141
azazel1024  103
KGB7  64
Adamm  64
speedingcheet...  57
jim769  56
TeHashX  55
RMerlin  4368
stevech  270
ryzhov_al  199
TeHashX  191
RogerSC  164
L&LD  163
joegreat  104
jlake  98
PrivateJoker  93
sinshiva  85
Most Viewed Threads* Hottest Threads*
Old Beta Version...  16985
Old ASUS...  16246
Old Asuswrt-Merli...  16088
Old 'Heartbleed'...  12224
Old Potential...  7522
Old Groundhog...  5946
Old Asus-Merlin...  5796
Old Linksys...  4538
Old Linksys...  4470
Old [TUTORIAL]...  2660
Old Asuswrt-Merli...  146
Old Beta Version...  112
Old Linksys...  104
Old Potential...  98
Old ASUS...  93
Old Groundhog...  49
Old Asus router...  43
Old [TUTORIAL]...  39
Old Asus-Merlin...  35
Old 'Heartbleed'...  33



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