How to control a TPLINK router with a python script

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.

How to control a TPLINK router with a python script

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.
How to control a TPLINK router with a python script
How to control a TPLINK router with a python script
2020-04-07 05:58:09 - last edited 2020-08-27 01:48:57
Model: Adapter  
Hardware Version: V6
Firmware Version:

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?

  1      
  1      
#1
Options
1 Accepted Solution
Re:How to control a TPLINK router with a python script-Solution
2020-08-27 01:48:43 - last edited 2020-08-27 01:48:57

@PrettyThunder 

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.

Landscape Mode - Tapo App for PadShare Your Pet Story. Win Free Tapo Care!Smart Action 2.0 Explore and meet the next level home automation.
Recommended Solution
  2  
  2  
#3
Options
9 Reply
Re:How to control a TPLINK router with a python script-Solution
2020-08-27 01:48:43 - last edited 2020-08-27 01:48:57

@PrettyThunder 

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.

Landscape Mode - Tapo App for PadShare Your Pet Story. Win Free Tapo Care!Smart Action 2.0 Explore and meet the next level home automation.
Recommended Solution
  2  
  2  
#3
Options
Re:How to control a TPLINK router with a python script
2020-12-19 05:12:11 - last edited 2021-01-22 09:50:31

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 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?

 

 

 

 

 

I relies upon your tp link model and firmware.

  0  
  0  
#4
Options
Re:How to control a TPLINK router with a python script
2021-01-27 16:11:56

@PrettyThunder never understood python, anyway thanks for posting!

  0  
  0  
#5
Options
Re:How to control a TPLINK router with a python script
2021-04-29 16:40:42

@PrettyThunder https://github.com/epsi95/TPLink-Python

  0  
  0  
#6
Options
Re:How to control a TPLINK router with a python script
2021-07-24 18:28:26

 

epsi95 wrote

@PrettyThunder https://github.com/epsi95/TPLink-Python

 

epsi95 wrote

@PrettyThunder https://github.com/epsi95/TPLink-Python

@epsi95 

  0  
  0  
#8
Options
Re:How to control a TPLINK router with a python script
2021-07-24 18:29:18
Please can you supprt me
  0  
  0  
#9
Options
Re:How to control a TPLINK router with a python script
2021-07-24 18:29:50
  0  
  0  
#10
Options
Re:How to control a TPLINK router with a python script
2022-02-28 17:24:46

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 ?

  0  
  0  
#11
Options
Re:How to control a TPLINK router with a python script
2022-06-28 07:13:07

  You can control Tp-Link with scripts easily as It works on here, you use it too.

  0  
  0  
#12
Options