-
-
Save takkumattsu/d3d34d6f5f12254f63f8b3a0a1d0e09a to your computer and use it in GitHub Desktop.
マイクラのログをdiscordに通知するスクリプト
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 | |
LOGFILE="/home/XXX/minecraft/logs/latest.log" | |
BOT_NAME="XXX" | |
DISCORD_URL="" | |
tail -F -n0 $LOGFILE | | |
sed -u -e 's/'\''/\\'\''/g' | | |
xargs -I @ curl -H "Content-Type: application/json" X POST -d '{"username": "'"$BOT_NAME"'", "content": "@" }' $DISCORD_URL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ハマったポイント
'
が含まれているのでそのままだとcurlに渡すときにエラーになる、sedで\
を付加してエスケープしている-u
オプションを付けることでバッファしないようにしている