-
-
Save valvallow/3021540 to your computer and use it in GitHub Desktop.
Wake-on-LANのマジックパケットを投げつけるだけ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ssh -i /home/valvallow/.ssh/kaisha/id_rsa valvallow@kaisha-no-server '~/wol-srv.sh' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
/home/valvallow/wol 1a 2b 3c 4d 5e 6f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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