How to control a TPLINK router with a python script
I wanted to know whether there is a tool that allows me to connect to a router and shut it down, and then reboot it from a python script.
I know that if I write in a python script: import os
and then do os.system("ssh -l root 192.168.2.1")
, I can connect through python to my router. But then, I don't know how to apply the router's password, and to log into it, in order to reboot it.
So after working on it a bit here is the code that I have written in order to connect to my router with an SSH session using a python script:
import os, urllib, urllib2, re
def InterfaceControl():
#os.system("echo training")
os.system("ssh -l root 192.168.2.1")
os.system("echo yes")
os.system("echo My_ROUTER_PASSWORD")
os.system("shutdown -r")
def main():
InterfaceControl()
if __name__=="__main__":
main()
The problem is that I still can not connect to my router with this code, and moreover, IDLE (the editor I use to write and run python script) crashes. Can anyone help me improve this code?
- Copy Link
- Subscribe
- Bookmark
- Report Inappropriate Content
Good day.
Sorry for the delay.
May I know the model number of your wireless router?
You could try to use the Tether APP or router’s web interface to manage the APP.
As for the python script, I am really sorry that we are not able to provide more details about it.
Thank you very much for your understanding and support.
- Copy Link
- Report Inappropriate Content
Good day.
Sorry for the delay.
May I know the model number of your wireless router?
You could try to use the Tether APP or router’s web interface to manage the APP.
As for the python script, I am really sorry that we are not able to provide more details about it.
Thank you very much for your understanding and support.
- Copy Link
- Report Inappropriate Content
PrettyThunder wrote
I wanted to know whether there is a tool that allows me to connect to a router and shut it down, and then reboot it from a python script.
I know that if I write in a python script:
import os
and then doos.system("ssh -l root 192.168.2.1")
, I can connect through python to my router. But then, I don't know how to apply the router's password, and to log into it, in order to reboot it.
So after working on it a bit here is the code that I have written in order to connect to my router with an SSH session using a python script:
import os, urllib, urllib2, re def InterfaceControl(): #os.system("echo training") os.system("ssh -l root 192.168.2.1") os.system("echo yes") os.system("echo My_ROUTER_PASSWORD") os.system("shutdown -r") def main(): InterfaceControl() if __name__=="__main__": main()
The problem is that I still can not connect to my router with this code, and moreover, IDLE (the editor I use to write and run python script) crashes. Can anyone help me improve this code?
I relies upon your tp link model and firmware.
- Copy Link
- Report Inappropriate Content
@PrettyThunder never understood python, anyway thanks for posting!
- Copy Link
- Report Inappropriate Content
@PrettyThunder https://github.com/epsi95/TPLink-Python
- Copy Link
- Report Inappropriate Content
epsi95 wrote
@PrettyThunder https://github.com/epsi95/TPLink-Python
epsi95 wrote
@PrettyThunder https://github.com/epsi95/TPLink-Python
- Copy Link
- Report Inappropriate Content
- Copy Link
- Report Inappropriate Content
@Salman0811 yes
- Copy Link
- Report Inappropriate Content
I have same question too. anyone can help.
I have the Archer-A10 and using browser to capture the login request.
It is using a 256 bytes on both username and password.
is it using RSA ?
- Copy Link
- Report Inappropriate Content
You can control Tp-Link with scripts easily as It works on here, you use it too.
- Copy Link
- Report Inappropriate Content
Information
Helpful: 1
Views: 11103
Replies: 9