Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 6306  / 1 Year ago, sun, december 4, 2022, 11:01:50

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>

More From » curl

 Answers
2

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.


[#32003] Monday, December 5, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
igeonlothe

Total Points: 370
Total Questions: 121
Total Answers: 114

Location: United States Minor Outlying Island
Member since Fri, Feb 5, 2021
3 Years ago
;