ruby script for wakeonlan not working in 10.6

Discussion in 'Mac Programming' started by doobs, Oct 4, 2009.

  1. macrumors regular

    Jul 19, 2008
    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?
    #!/usr/bin/env ruby
    require 'socket'
    include Socket::Constants
    mac = 'XX:XX:XX:XX:XX:XX'   #correct mac omitted for posting
    ip = ''
    @magic ||= ("\xff" * 6)
    mac_addr = mac.split(/:/).collect {|x| x.hex}.pack('CCCCCC')
    @magic[6..-1] = (mac_addr * 16)
    @ip_addr = ip
    sock =
    sock.setsockopt( SOL_SOCKET, SO_BROADCAST, 1 )
    sock.connect( @ip_addr, Socket.getservbyname( 'discard', 'udp' ) )
    sock.send( @magic, 0 )
  2. macrumors 6502

    Mar 8, 2009
    Denver, CO
    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.

Share This Page