Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

doobs

macrumors regular
Original poster
Jul 19, 2008
136
0
I have a WakeOnLan ruby script that I execute on my MacBook Pro in order to turn on a specific Ubuntu Linux machine on my LAN. This script worked under OS X 10.5, but no longer works on 10.6. Any ideas?
Code:
#!/usr/bin/env ruby

require 'socket'
include Socket::Constants

mac = 'XX:XX:XX:XX:XX:XX'   #correct mac omitted for posting
ip = '255.255.255.255'

@magic ||= ("\xff" * 6)
mac_addr = mac.split(/:/).collect {|x| x.hex}.pack('CCCCCC')
@magic[6..-1] = (mac_addr * 16)
@ip_addr = ip
sock = UDPSocket.new
sock.setsockopt( SOL_SOCKET, SO_BROADCAST, 1 )
sock.connect( @ip_addr, Socket.getservbyname( 'discard', 'udp' ) )
sock.send( @magic, 0 )
 
I have a WakeOnLan ruby script that I execute on my MacBook Pro in order to turn on a specific Ubuntu Linux machine on my LAN. This script worked under OS X 10.5, but no longer works on 10.6. Any ideas?
Code:
#!/usr/bin/env ruby

require 'socket'
include Socket::Constants

mac = 'XX:XX:XX:XX:XX:XX'   #correct mac omitted for posting
ip = '255.255.255.255'

@magic ||= ("\xff" * 6)
mac_addr = mac.split(/:/).collect {|x| x.hex}.pack('CCCCCC')
@magic[6..-1] = (mac_addr * 16)
@ip_addr = ip
sock = UDPSocket.new
sock.setsockopt( SOL_SOCKET, SO_BROADCAST, 1 )
sock.connect( @ip_addr, Socket.getservbyname( 'discard', 'udp' ) )
sock.send( @magic, 0 )

Have you tried debugging with something like tcpdump on either the Mac or the Linux box? That would confirm if you are sending/receiving packets as well as the contents of the packet (using the appropriate flags).

You might want to add some debug print statements to your script to see if it finishes correctly.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.