title: ssh connection to a router with a python script
body: <p>I wanted to know whether there is a possibility to use a python script in order to connect to a router and control the interface (shut down, restart wireless network etc..) with an ssh connection.</p>
  
  <p>SO far I wrote these lines,but still it does not work. When i look to the terminal I see that everything is blocked at the point when my script should echo the password for the router to finalize the connection. How can I correct this please ?</p>
  
  <p>Here are the lines :</p>
  
  <pre><code>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()
  </code></pre>
  
  <p>Thank you so much in advance</p>