I am using following script to reboot my router using Telnet:
#!/usr/bin/env python
import os
import telnetlib
from time import sleep
host = "192.168.1.1"
user = "USER"
password = "PASSWORD"
cmd = "system restart"
tn = telnetlib.Telnet(host)
sleep(1)
tn.read_until("Login: ")
tn.write(user + "\n\r")
sleep(1)
tn.read_until("Password: ")
tn.write(password + "\n\r")
sleep(1)
tn.write(cmd + "\n\r")
I don't know why but removing "\r" breaks this code. So what does "\r" do in this script and when do I use "\r" in general?
Note: I know about "Carriage Return" but still could not figure out it is used in my script. I am running this script in Linux.
 
     
     
     
     
     
    