PDA

View Full Version : WOL (Wake on LAN) script - start a computer remotly


dragonneus
2006-01-07, 08:54
trying to use the wol script i have added all mac addresses of the pcs i wish to activate via xbmc wol script, all nics are wol capable and has been confirmed by seeing it on my switch when all machines are off. all pcs in question have wol activated in the cmos settings on the motherboards. even using an xover cable directly doesnt work.

Asteron
2006-01-09, 20:01
can you send a wol from pcs to eachother? some older motherboards require a special cable going from the nic to the machine for it to work. i would make sure that this signal works before trying it on the xbox.

dragonneus
2006-01-10, 11:08
ill try that thankyou for the insight. when you say special cable do you mean a crossover?

sCAPe
2006-01-10, 15:08
@asteron:

my network card on my pc is onboard, thus there is no wol cable from the netword card to the motherboard.

the wol script is also not functioning for me. i have enabled wol in my computers bios. i have entered the correct mac-adress in the script. but i cannot wakup my pc from the xbox.

is the script working for anybody? can somebody confirm this script works in general?

any hints or tips?

Asteron
2006-01-10, 17:54
ill try that thankyou for the insight. when you say special cable do you mean a crossover?
there is such a thing as a wol cable (small two wires) that connects an nic to the motherboard that could possibly be required (not sure though).

for wol to work it must construct a magic packet that contains
ffffffffffff followed by the mac address 16 times.

00 ff ff ff ff ff ff
06 00 e0 98 13 45 e2
12 00 e0 98 13 45 e2
**
96 00 e0 98 13 45 e2
i dont have wol setup but remember looking at that script a while ago. you might need to be careful about router settings i suppose? the router might block broadcast traffic. maybe you should send it on a port forwarded to the target computer.

sCAPe
2006-01-10, 18:27
i dont have wol setup but remember looking at that script a while ago. you might need to be careful about router settings i suppose? the router might block broadcast traffic. maybe you should send it on a port forwarded to the target computer.
router settings. that could be the problem. my computer is connected to the router and the xbox is connected to the router too.

could you please help me which port exactly and which protocol tcp/udp to forward in the router config? so that the magic packet for wakeonlan arrives to my computer and will not be blocked by my router.
i think i cannot configure any port in the wol script, or can i ?

thanks in advance.

Nuka1195
2006-01-10, 19:32
do you have a link light even with power off? you should for wol to work.

Asteron
2006-01-10, 20:32
the magic packet shouldnt care about port... looking at the code it looks like this

# broadcast it to the lan.
sock = socket.socket(socket.af_inet, socket.sock_dgram)
sock.setsockopt(socket.sol_socket, socket.so_broadcast, 1)
sock.sendto(send_data, ('<broadcast>', 7))

can be changed to something like
# send to specific computer
sock = socket.socket(socket.af_inet, socket.sock_dgram)
sock.sendto(send_data, ('host_ip', 'port_number'))
replace those last two fields with the pc's local address.
this makes the script less general of course. try setting the router to forward the port to the correct ip.

dragonneus
2006-01-13, 08:47
i will certainly try your idea. i have to say though that even if i use a crossover from the xbox directly to the pc (removing the router and switch) it still doesnt work. anyone else have any ideas. i mean i have a seperate room thats my pc lab its not difficult to just turn them on but it would be cool to get this to work.

dragonneus
2006-01-13, 08:48
and yes nuka1195 i have all link lights on my switch when the power is off to the pcs in question.

mjhodgson
2006-01-13, 21:37
hi

usually the pc has to be shutdown in a state that allows it to listen for wake-on-lan packets. this means that in windows (2000 and xp) you need to tell the driver to do this. if you have let windows use it's driver (a microsoft provided one) when you installed the pc/network card, then you probably won't have this option. i had to install the ones from the 3com site. this will allow you to go to (roughly) control panel - computer management - device manager - network adapters - properties. on the 3com drivers i have under the advanced tab "rwu magic packet", this needed to be set to enable (plus a reboot) for wol to work. you may have something similar under your network drivers.

under linux, i believe a tool called ethtool can set this up, but i've never got it to work with my network cards.


mjh

dragonneus
2006-01-18, 07:43
ahhh coolt he info ive been looking for, ill try it and let you all know what ive found

sCAPe
2006-01-18, 21:26
the magic packet shouldnt care about port... *looking at the code it looks like this

* *# broadcast it to the lan.
* *sock = socket.socket(socket.af_inet, socket.sock_dgram)
* *sock.setsockopt(socket.sol_socket, socket.so_broadcast, 1)
* *sock.sendto(send_data, ('<broadcast>', 7))

can be changed to something like
* *# send to specific computer
* *sock = socket.socket(socket.af_inet, socket.sock_dgram)
* *sock.sendto(send_data, ('host_ip', 'port_number'))
replace those last two fields with the pc's local address.
this makes the script less general of course. *try setting the router to forward the port to the correct ip.

i have a broadcom onboard network card, and changed the settings in windows xp device manager to wake on lan = magic frame and i also tried wake on lan = wake up frame. nothing works.

but you suggested to forward the port in my router config. but how will that work, because if the pc is off, then the router cannot contact any ip-adress. it has to use the mac-adress like the script does.

so, before i am doing more on trying this out i would like to know if this script is already working for somebody ??

Asteron
2006-01-18, 22:06
the pc should show up on the router if it has wol even if it is off. even when off the nic is somewhat powered to listen for the packet. i dont actually have experience with wol but am just saying how i understand it to work.

jepper
2007-01-25, 17:39
hi all

i made remote wol as an experiment since wake on lan doenst work for me.
i thought the router was a problem so i wrote a script that connects to a site an d that site (writen by myself, source included) that send the magic packet

it has a few advantages over the wol script:
- wake any pc you want (doenst have to be in your lan)
- can bypass routers if you use NAT-forwarding


but it didnt work for me, my router thinks its an attack and whatever i tried it keeps killing the waking packet

so here's the project. Its not done yet but maybe some python devver likes this script and wants to make this into something usefull!

NOTE ! there is no readme and no fancy settings menu. I cant even try if it works!

link:
http://test.familie-gerbers.nl/RemoteWOL.zip


peace out

Jasper

jepper
2007-01-25, 17:46
ow and it has a really ugly icon :P

JoJa15
2007-02-14, 17:30
I am working on an advanced Wake On Lan script for XBMC. So far the WOL function is working and I would like to add the ability to show if a machine is up or off (I figured I would do so by pinging the machine and seeing if I get a response). I would also like to add the ability to remotely shutdown a computer from the XBMC script. Does anyone have a code snippet for pinging an IP, a code snippet for shutting down a remote Windows machine, and a code snippet for sending a HTTP request?

Here is my current setup:

Latest XBMC
FreeNAS (media server running on FreeBSD. Can be shutdown from web interface so I planned on just sending that same web button click from XBMC to shutdown the FreeNAS server)
Windows XP machine with folder share (What packet is sent over the network to remotely shutdown a Windows XP machine?)

My hope is to have a script then when you start it will list all your remote computers/servers and show if they are currently on/off. Then you can select a server and turn it off if it is on or turn it on if it is off.

Thank you in advance for any help provided.

- John

timdog82001
2007-02-18, 01:17
I don't know if its completely necessary, but I know the shutdown on lan script already on xbmcscripts uses a client that you have to run on the computer in order to to tell it to shutdown...Would be great if you could do it without it though

mwg47x
2007-04-06, 23:51
JoJa15,
Did you ever get this working the way you wanted?
I'd be interested in seeing it if you wouldn't mind.

wigwam
2007-05-06, 03:14
i would also like to try this so anyone who has it working please tell us what to do!

kricker
2008-07-09, 00:31
I am trying to get my Xbox to send a WOL to my server when XBMC starts. I understand how to use autoexec.py. The problem lies in trying to find the correct WOL script. I have the tweaked WOL, but it opens a GUI to select the PC to wake. This is great if I have other computers to wake, but I want it to always wake the server and not show a GUI when running at startup. All my searches for the older WOL showed either dead links or the code I lifted from the posts did nothing. Can anyone please help me out?

ozNick
2008-07-09, 07:05
I am trying to get my Xbox to send a WOL to my server when XBMC starts. I understand how to use autoexec.py. The problem lies in trying to find the correct WOL script. I have the tweaked WOL, but it opens a GUI to select the PC to wake. This is great if I have other computers to wake, but I want it to always wake the server and not show a GUI when running at startup. All my searches for the older WOL showed either dead links or the code I lifted from the posts did nothing. Can anyone please help me out?

I had a look and couldn't find it so the code is below (change the MAC). You can wake more than 1 by duplicating the WakeOnLan(MAC) line.

Alternatively you can use Nuka's Plug-in maker (in SVN) to send a WOL packet when the desired share is required.


Cheers Nick


# Wake-On-LAN
#
# Copyright (C) 2002 by Micro Systems Marc Balmer
# Written by Marc Balmer, marc@msys.ch, http://www.msys.ch/
# This code is free software under the GPL

import struct, socket

def WakeOnLan(ethernet_address):

# Construct a six-byte hardware address

addr_byte = ethernet_address.split(':')
hw_addr = struct.pack('BBBBBB', int(addr_byte[0], 16),
int(addr_byte[1], 16),
int(addr_byte[2], 16),
int(addr_byte[3], 16),
int(addr_byte[4], 16),
int(addr_byte[5], 16))

# Build the Wake-On-LAN "Magic Packet"...

msg = '\xff' * 6 + hw_addr * 16

# ...and send it to the broadcast address using UDP

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.sendto(msg, ('<broadcast>', 9))
s.close()

# Example use
WakeOnLan('aa:bb:cc:dd:ee:ff') # My PC

kricker
2008-07-09, 09:19
That is the exact code I tried to lift and use. When I run it nothing happens. If I run the tweaked WOL script it works properly.

I looked for Nuka's Plug-in maker and could not find it. Is it only in the SVN? So I need to find it there? I'd love for it to only send the WOL when the share is requested. That is even better than always waking the server at boot up.

kricker
2008-07-09, 09:48
I got the script working now. I changed the port from 9 to 7. I thought I did that before and it didn't work...oh well. It is now. :)

ozNick
2008-07-09, 10:02
That is the exact code I tried to lift and use. When I run it nothing happens. If I run the tweaked WOL script it works properly.

I tested before I posted, and copied and pasted from the forums just to double check, and it all works fine. Have you tested as just a standalone script?

I looked for Nuka's Plug-in maker and could not find it. Is it only in the SVN? So I need to find it there? I'd love for it to only send the WOL when the share is requested. That is even better than always waking the server at boot up.
The repositry is covered in this thread http://xbmc.org/forum/showthread.php?t=29911

The plug-in created uses a modified version of the script I posted.

Cheers Nick

kricker
2008-07-09, 16:52
Thanks for the info. Look above, I got it working. I'm not sure why it didn't earlier. Maybe a bad copy paste. Thanks again.

kricker
2008-07-10, 20:17
Followup,
So now that I got the script working, I ended up just adding:
<onclick>XBMC.RunScript(Q:\scripts\Wake\wakePVR.py)</onclick>
to the items on the home screen that access content on that computer. This way it only wakes that PC when it needs content from it. So far it works like a champ. The only downside is having to edit the homescreen whenever I update the skin.