Telnet client library in Python? Send Telnet commands from XBMC?
#16
i've had a look through the yac and the wake-on-lan scripts, which are fairly complicated to follow (for a stupid python beginner like me). some of it makes sense, most of it does not, any chance i can get a stripped down version using a class like telnetlib?

thanks again.

jt
Reply
#17
can you post the full script that you created using the telnetlib class?

i tried the script you provided above, but it doesn't even open an ok dialog box for me, am i missing something?

thanks

jt



Reply
#18
actually the yac script used to be more simple but it looks like he added several extra modes and data formats so its not as good an example as it used to be. it is comprehensive in socket usage though. i stripped out all the data formatting code and this is the raw connection stuff which isnt all that much. this is kinda low level network communication but it's not like you have to allocate output buffers or format the ip header or anything.

Quote:import socket

# these setup the socket to send individual packets
# use sock.sock_stream for continuous data over
# several packets
s = socket.socket(socket.af_inet, socket.sock_dgram)
# i think the socket calls like receive will wait until the
# data arrives before returning with this
s.setblocking(1)
# you bind your end of the locket to a local port number
# and name (use '' for the name to just use normal)
s.bind((local_name, localport_number))

data = something;
# sends a packet with a payload of 'data'
s.sendto(data, (remote_ip, remote_port))
# receive reply data
reply = s.receive(numbytes)


# you can also wait for and receive an incomming connection
# like this
s.listen(1)
conn, remote_addr = s.accept()
data = conn.recv(1024)

hope that makes it clearer Smile i dont know much about the telnet stuff.



Reply
#19
Hi

I'm trying to run a script from my xbox that access's my LinkStation via telnet.

The script is basic:

---------------------------------------------------------------------
from telnetlib import Telnet

tn = Telnet('192.168.0.9', 23)

tn.read_until('login:')
tn.write('root\n')

tn.read_until('password:')
tn.write('********\n')

tn.read_until('#')
tn.write('shutdown -r now\n')

tn.close()
---------------------------------------------------------------------

But doesn't work for sme reason. I'm not sure if the Telnet feature is working properly. I'm running the latest T3CH build and the latest MC360 dash.

Is there anyway of checking logs or running tests to see if Telnet is failing. To be honest is Telnet even built into the T3CH builds??

Any help appreciated.
Reply
#20
it's interesting, I go to make my script for reconnet my adsl router from xbmc. Reasons: limit 71 minutes from megavideo. I use videomonkey-atrapavideo (online stream flash for films and series in Spanish in web sersiesyonkis.com and peliculasyonkis.com).
Reply

Logout Mark Read Team Forum Stats Members Help
Telnet client library in Python? Send Telnet commands from XBMC?0