1

I read from this page how to restart the router using curl.
I got the command for my router

http://192.168.1.1/Forms/tools_system_1?restoreFlag=0&Restart=RESTART

It works when i put it in browser's address bar but when I use curl

curl -u admin:mypass 'http://192.168.1.1/Forms/tools_system_1?restoreFlag=0&Restart=RESTART'

It does not work.
no output is there in Terminal Screen.
EDIT
Result of --

curl -i -u admin:mypass 'http://192.168.1.1/Forms/tools_system_1?restoreFlag=0&Restart=RESTART'

gives this--

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="450TC1"
Content-Type: text/html
Transfer-Encoding: chunked
Server: RomPager/4.07 UPnP/1.0
EXT:

<html>
<head>
<title>Protected Object</title></head><body>
<h1>Protected Object</h1>This object on the RomPager server is protected

Output of

curl --verbose -u admin:mypass 'http://192.168.1.1/Forms/tools_system_1?restoreFlag=0&Restart=RESTART'

Gives this --

* About to connect() to 192.168.1.1 port 80 (#0)
*   Trying 192.168.1.1... connected
* Server auth using Basic with user 'admin'
> GET /Forms/tools_system_1?restoreFlag=0&Restart=RESTART HTTP/1.1
> Authorization: Basic YWRtaW46c2hhcmluZ2FuMDA3
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: 192.168.1.1
> Accept: */*
> 
< HTTP/1.1 303 See Other
< Location: http://192.168.1.1/progress.htm
< Content-Length: 0
< Server: RomPager/4.07 UPnP/1.0
< EXT:
< 
* Connection #0 to host 192.168.1.1 left intact
* Closing connection #0

But curl -u admin:mypass 192.168.1.1 returns this. Works fine!

<html>
<head>
<title>
</title><meta http-equiv="Content-Type" content="text/html; charset=
iso-8859-1">
<meta http-equiv=Content-Script-Type content=text/javascript>
<meta http-equiv=Content-Style-Type content=text/css>
</head><frameset rows="65,75,*" framespacing="0" border="0" frameborder="0">
<frame name="header" noresize src="status.html" marginwidth="0" marginheight="0">
<frame name="navigation" noresize src="navigation-status.html" marginwidth="0" marginheight="0">
<frame name="main" noresize src="../status/status_deviceinfo.htm" marginwidth="0" marginheight="0">
</frameset><noframes>
</noframes>
</html>
3
  • Try running curl with additional switches, like -i and --verbose, e.g. curl -i -u admin:mypass 'http://… etc. The router doesn't return any content in body, you should investigate HTTP headers instead; add output of these commands to your question so we can better understand what's going on. It's possible the router doesn't accept HTTP authentication and uses cookies instead. Or maybe the router accepts only the POST request for this command.
    – jnv
    Mar 27, 2013 at 18:53
  • using wget instead of curl works Mar 27, 2013 at 19:09
  • after sending that command in web browser, 192.168.1.1/progress.htm gets opened up so i tried curl on this address, but only 2 times out of 4, the router restarted. It gave the same error "RomPager server is protected" 2 times. Mar 27, 2013 at 19:46

2 Answers 2

1

Stick to what works for you. Based on your now previous comment, it's possible there's some special character in your password; try wrapping your credentials in quotes, e.g. -u "admin:pass".

If Wget works, use it instead; you can use -O - switch to redirect output to console (similar to Curl's default behaviour), instead of saving the file.

Sending a data as POST request may also work, e.g.:

curl -u 'admin:mypass' --form 'restoreFlag=0&Restart=RESTART' 'http://192.168.1.1/Forms/tools_system_1'

Also notice that in your output, router returned different message for -i and --verbose flags—401 Unauthorized for -i and 303 See Other for --verbose. The latter, I assume, lead to a successful restart. I don't think that flags are related to router's behaviour, it seems to be completely random.

Anyway, I don't think this question is specific for Ubuntu in any way, I recommend asking at SuperUser.

0

co-incidentally i was trying to reboot the router so decided to make a search rather than reinventing the wheel so i landed here.

i found something interesting just run this, just run this directly your router will be rebooted

curl --verbose -u user:pass 'http://192.168.1.1/progress.htm'

or

curl --verbose -u user:pass 'http://192.168.1.1/progress.htm' -e 'http://192.168.1.1/maintenance/tools_system.htm'

or

wget -v -F -S --http-user=user --http-password=pass --ignore-length --referer="http://admin:[email protected]/maintenance/tools_system.htm" "http://192.168.1.1/progress.htm" -O "info.output.file"

you can remove the -v and -S from wget command

sometimes curl fails at authentication randomly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .