Changeset 372 for misc/wakeup
- Timestamp:
- Apr 26, 2012, 6:02:58 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
misc/wakeup
r371 r372 7 7 import sys 8 8 9 def wake_on_lan(macaddress ):9 def wake_on_lan(macaddress, broadcast): 10 10 """ Switches on remote computers using WOL. """ 11 11 … … 31 31 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 32 32 sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) 33 sock.sendto(send_data, ( '<broadcast>', 7))33 sock.sendto(send_data, (broadcast, 7)) 34 34 35 35 … … 39 39 'sb' : '00:13:d4:06:0c:79' } 40 40 if len(sys.argv) == 1: 41 print "Usage: %s <macaddr|host> " % sys.argv[0]41 print "Usage: %s <macaddr|host> [<broadcast>]" % sys.argv[0] 42 42 print "" 43 43 print "Hosts configured: " … … 46 46 sys.exit(64) 47 47 48 if hostmac.has_key(sys.argv[1]): 49 wake_on_lan(hostmac[sys.argv[1]]) 50 else: 51 wake_on_lan(sys.argv[1]) 48 try: 49 mac = hostmac[sys.argv[1]] 50 except KeyError: 51 mac = sys.argv[1] 52 53 try: 54 broadcast = sys.argv[2] 55 except IndexError: 56 broadcast = '<broadcast>' 57 58 wake_on_lan(mac, broadcast)
Note:
See TracChangeset
for help on using the changeset viewer.