Connecting to lan web server
#1
hi all

i'm trying to make a script to switch off my media server. so far it works quite well except for the fact the lan ips are hardcoded into the script but i would like to use server names rather than ips (they are dhcp assigned on my network so somtimes change)

why can't i use the (windows) server name as is possible on win32 python?

heres the script as it is now, works on xbmc and win32 python
Quote:import urllib
temp = urllib.urlopen('http://usernm:[email protected]:9000/action.htm?action=hibernate').read()

but this is how i would like it be, this only works on win32 python
Quote:import urllib
temp = urllib.urlopen('http://usernm:password@saturn:9000/action.htm?action=hibernate').read()

in my debugging i have tried importing httplib and using httplib.httpconnection(url) with the same effect

also tried importing socket and using socket.getfqdn(servername)/gethostbyname(servername) with some string concat to create the url but it never worked either


i've never scripted python before so any suggestions would be welcomed

tia
Reply
#2
afaik, you can't. use a dns name or ip.
--jaga
Reply
#3
(jaga @ dec. 28 2004,15:07 Wrote:afaik, you can't. use a dns name or ip.
bbzzzzzth

we have a winner...me! Wink

you need pysmb samba/netbios client-python libs (http://miketeo.net/projects/pysmb/index.html),

thelibs also allow python file upload + download if anyone's interested Smile ... read the discliamer, experimental only need to be tested with xp, winme, opensource, very relaxed licence, designed for python versions<=2.3

Quote:import urllib, smb,nmb

ip = nmb.netbios().gethostbyname('saturn')[0].get_ip()

temp = urllib.urlopen('http://usernm:password@'+ip+':9000/action.htm?action=hibernate').read()

i tested this script on xp, did not work, poss due to conflict with xp's built in netbios client or incompatability, worked fine on xbox

cheers
Reply

Logout Mark Read Team Forum Stats Members Help
Connecting to lan web server0