xboxscene.org forums

Author Topic: Anyone Have A Basic Telnet Script I Could Use?  (Read 330 times)

Sogay toregister

  • Archived User
  • Newbie
  • *
  • Posts: 8
Anyone Have A Basic Telnet Script I Could Use?
« on: December 19, 2004, 06:22:00 AM »

Hi. Does anyone have a basic telnet script I could use on XBMC?

The reason why I ask is that I have a couple of machines that I would like to send automatic telnet commands to, especially my router. For example, occasionaly xlink kai on my linksys wrt54g will lockup, and I end up needing to reboot the router. Rather than logging onto my PC and telneting in, is there a script anyknow knows of that is able to telnet to an IP address, and then from there, I can add my command line commands into the script? Basically, I'd just have my username/login name entered in the script so it logs into the router automatically. Then I'd have it to a taskill, and finally a reboot command.

Thanks for any help you can provide.
Logged

friedgold

  • Archived User
  • Sr. Member
  • *
  • Posts: 266
Anyone Have A Basic Telnet Script I Could Use?
« Reply #1 on: December 28, 2004, 08:18:00 AM »

Here's some code I use to shutdown my pc remotely:

CODE
from telnetlib import Telnet

tn = Telnet('192.168.1.100', 23)

tn.read_until('login:')
tn.write('xbox\r')

tn.read_until('password:')
tn.write('xbox\r')

tn.read_until('>')
tn.write('shutdown -s -t 120\r')

tn.read_until('>')
tn.write('exit\r')

tn.close()


Pretty basic but does the job. Would have thought something similar would work
for your router
Logged