æ¦è¦
- PCã®åã§ï¼éããå¦çãçµããã®ããã£ã¨å¾ ã¤ã®ã¯æéã®ç¡é§ã§ã
- éããå¦çãçµããã¨ï¼èªå㧠LINE ã«éç¥ãéãæ¹æ³ãç´¹ä»ãã¾ã
- å¦çå®äºï¼ã®LINEéç¥ãå±ãã¾ã§ã¯ï¼PCãªãã¦æ¾ç½®ãã¦æéãæå¹æ´»ç¨ãã¾ããã
æé
LINEå ¬å¼ãæä¾ãã¦ããéç¥é£æºç¨ã®APIï¼LINE Notifyï¼ã使ãã¾ã
APIã¨ãã£ã¦ãè²»ç¨ã¯ä¸è¦ï¼ç¡æã§ããã«ä½¿ãã¾ã
åæç»é²
1) Lineã®ã°ã«ã¼ããä½æãã
APIï¼LINE Notifyï¼ã¯ï¼ã°ã«ã¼ãå®ã«éç¥ãéä¿¡ããä»çµã¿ã§ã
ãã®ããï¼éç¥ãåä¿¡ããã°ã«ã¼ãããããããä½æããå¿
è¦ãããã¾ã
èªåã²ã¨ãããéç¥ãåãåããªãå ´åã§ãï¼ã°ã«ã¼ããå¿
è¦ã§ãï¼
ã¹ãããªã©ã§Lineã®ã¢ããªãèµ·åãã¦ï¼ã¢ããªä¸ã§Line ã®ã°ã«ã¼ããä½æãã¾ãï¼
ååã¯ãªãã§ãOKã§ãï¼
2) APIï¼LINE Notifyï¼ã®è¨å®
ãã©ã¦ã¶ã§ä»¥ä¸ã®URLãéãã¾ã
https://notify-bot.line.me/ja/
LineIDã§ãã°ã¤ã³ï¼ãã°ã¤ã³å¾ãã¤ãã¼ã¸ãéãã¾ã
3) ã¢ã¯ã»ã¹ãã¼ã¯ã³ã®ä½æ
å ã»ã©ã®1)ã§ä½æããã°ã«ã¼ããé¸æãã¦ï¼ã¢ã¯ã»ã¹ãã¼ã¯ã³ãä½æãã¾ã
ã¢ã¯ã»ã¹ãã¼ã¯ã³ã¯ãã¹ã¯ã¼ãã®ãããªãã®ã§ãï¼
4) ã°ã«ã¼ãã« LINE notifyãæå¾
Lineã®ã¢ããªä¸ã§ï¼ 1)ã§ä½æããã°ã«ã¼ãã« LINE notify ãæå¾ ãã¾ã
以ä¸ã§åæç»é²ã¯ããã¾ãã§ã
ã¹ã¯ãªããã®ä½æ
éç¥éä¿¡ç¨ã®ã¹ã¯ãªãããä½æãã¾ã
ã¯ã³ã©ã¤ãã¼ã§ãè¨è¿°ã§ããã®ã§ããï¼ä¾¿å©ãªã®ã§ãã¡ã¤ã«åãã¾ã
以ä¸ã®å 容ã linenotify.sh ã¨ãããã¡ã¤ã«åã§ä¿åãã¦ããã¾ã
#!/bin/sh MSG="$@" TOKEN="ä¸è¨ã®3)ã§ä½æããã¢ã¯ã»ã¹ãã¼ã¯ã³ã®æåå" wget -q \ --header="Authorization: Bearer ${TOKEN}" \ --post-data="message=${MSG}" \ https://notify-api.line.me/api/notify
ä»çµã¿ã¨ãã¦ã¯åç´ã§ï¼HTTPSçµç±ã§ï¼POSTã¡ã½ããã§ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ããã ãã§ãï¼
å®è£ 㯠wget ã³ãã³ãã使ã£ã¦ãã¾ãï¼wget ãã¤ã³ã¹ãã¼ã«ããã¦ãªãå ´å㯠curl ãªã©ãã¤ããã¾ãããï¼
åä½ç¢ºèª
ãã¹ãéã£ããã£ã¬ã¯ããªã«ä¸è¨ã® linenotify.sh ã®ã¹ã¯ãªãããã¡ã¤ã«ãé ç½®ãã¦ï¼linenotify.sh ãå®è¡ãã¾ã
ãã¨ãã° "Hello"ã¨ããæååãLineã§éãããå ´åã¯ä»¥ä¸ã®ã³ãã³ããå®è¡ãã¾ã
$ linenotify.sh Hello
ç¾å¨æå»ãéç¥ãããå ´åã¯
$ linenotify.sh `date`
ãå®è¡ãã¾ã
ããã¯ï¼ç¾å¨æå»ãåºåãã dateã³ãã³ããå®è¡ãã¦ï¼ãã®å®è¡çµæã®æååï¼ã¤ã¾ãç¾å¨æå»ï¼ã line ã«éç¥ããåä½ã«ãªãã¾ã
使ãæ¹ï¼ç°¡åãªä¾ï¼
ãã¨ãã°éããå¦çã command1 ã¨ããã¨
$ command1 ; linenotify.sh "command1 done"
ã¨å®è¡ããã°ï¼çµäºå¾ããã« "command1 done"ã¨ããæååãLineã«éç¥ããã¾ã
使ãæ¹ï¼å°ãé«åº¦ãªä¾ï¼
comannd1ã失æããå ´åã ãLINEã§éç¥
$ command1 || linenotify.sh "command1 failed!"
comannd1ãæåããå ´åã ãLINEã§éç¥
$ command1 && linenotify.sh "command1 succeed!"
å¿ç¨ä¾
Lineã«ç°¡åã«éç¥ãéä¿¡ã§ããã®ã§ï¼ãããããªä½¿ãæ¹ãã§ãã¾ã
ä¸æéã«ä¸åï¼ãã°ãã¡ã¤ã«ãç£è¦ï¼è¡æ°ãå ±åããã
ãã°ãã¡ã¤ã«ã/var/log/logfile ã¨ããã¨ï¼wc -l ã§è¡æ°ãæ°ããã ããªã®ã§
while /bin/true; do linenotify.sh $(wc -l /var/log/logifle); sleep 3600; done
ä¸æéã«ä¸åï¼ãã°ãã¡ã¤ã«ãç£è¦ï¼ç¹å®ã®ã¡ãã»ã¼ã¸ã®æç¡ãå ±åããã
ãã°ãã¡ã¤ã«ã/var/log/logfile ã¨ããã¨ï¼grepã§ç¹å®ã®ã¡ãã»ã¼ã¸ãæ¤ç´¢ããã ããªã®ã§
while /bin/true; do linenotify.sh $(grep keyword /var/log/logifle); sleep 3600; done
ã¾ã¨ã
ãã®ã¨ã³ããªã¯ä»¥ä¸ã®è¨äºã«è§¦çºããã¦ä½æãã¾ãã
https://zenn.dev/magicmoment/articles/play-sound-command-20241205
ã¨ã³ã¸ãã¢ã»ããã°ã©ãããã£ã¦ããã¨ï¼
- ãµã¼ãã¼ã«æºã¾ã£ã大éã®ãã°ãã¡ã¤ã«ã®éè¨
- åç»ã®ã¨ã³ã³ã¼ã
- 大è¦æ¨¡ããã¸ã§ã¯ãã®ãã«ã
- ãã¹ãã±ã¼ã¹ã®å®è¡
- æ©æ¢°å¦ç¿/LLMã®ãã¡ã¤ã³ãã¥ã¼ãã³ã°
- ãã®åå¦ç
ãªã©ï¼é·ãå¦çã»éããå¦çã¯æ²¢å±±ç»å ´ãã¾ã
å¤å ¸çãªæ¹æ³ã¨ãã¦ã¯
$ make ; beep
ã
$ make ; eject
ã§ã
ã§ããã½ã³ã³ã®åã§ãã£ã¨å¦çãçµããã®ãå¾ ã¤ã®ã¯ï¼æéã®ç¡é§ã§ããããã¾ããï¼æéããã£ãããªãï¼
ããã§ä»åã¯ï¼æéãæå¹æ´»ç¨ããããã®æ段ã¨ãã¦ï¼LINEéç¥ã使ãæ¹æ³ãç´¹ä»ãã¾ããï¼ãã®æ¹æ³ã使ãã°ï¼PCãæ¾ç½®ãã¦ä¼æ©ãé£äºï¼æã¡åããã«åºãããã¨ãã£ãæ°ããé¸æè¢ãçã¾ãã¾ãï¼
追è¨
ãã®ã¨ã³ããªãæ¸ãã¦ãã¦æ°ãã¤ããã®ã§ããï¼APIï¼LINE Notifyï¼ã¯2025å¹´ï¼æã§ãµã¼ãã¹çµäºï¼ä»å¾ã¯æ°ããAPIã«ç§»è¡ããããã§ãï¼
è¿æ¥ä¸ã«æ°ããAPIã«ä¹ãæããã®ã§ï¼ãã®æã¯ã¾ãå¥è¨äºã§æé ãªã©ãå ¬éããäºå®ã§ã