Skip to content

Instantly share code, notes, and snippets.

@valvallow valvallow/wol-local.sh forked from aharisu/wol.scm
Created Jun 30, 2012

Embed
What would you like to do?
Wake-on-LANのマジックパケットを投げつけるだけ
#!/bin/sh
ssh -i /home/valvallow/.ssh/kaisha/id_rsa valvallow@kaisha-no-server '~/wol-srv.sh'
#!/bin/sh
/home/valvallow/wol 1a 2b 3c 4d 5e 6f
#!/usr/local/bin/gosh
(use gauche.uvector)
(use gauche.net)
(define (usage)
(print "usage: wol <mac address>")
(print "example: wol 1a 2b 3c 4d 5e 6f")
(exit 1))
(define (main args)
(when (or (null? (cdr args))
(not (= 6 (length (cdr args)))))
(usage))
(let1 mac-addr (list->u8vector
(map (cut string->number <> 16)
(cdr args)))
(print (cdr args))
(print mac-addr)
(let ([buf (make-u8vector (* 6 17))]
[sock (make-socket AF_INET SOCK_DGRAM)])
(dotimes [i 6] (u8vector-set! buf i 255))
(dotimes [i 16] (u8vector-copy! buf (* (+ i 1) 6) mac-addr))
(socket-setsockopt sock #xffff #x20 1)
(socket-sendto sock buf
(make <sockaddr-in> :host :broadcast :port 7))
(print "done"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.