ruby script for wakeonlan not working in 10.6

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

  1. macrumors regular

    Joined:
    Jul 19, 2008
    #1
    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 )
    
     
  2. macrumors 6502

    Joined:
    Mar 8, 2009
    Location:
    Denver, CO
    #2
    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