announce.sh

来自「打魔兽战网的都知道他是什么」· Shell 代码 · 共 68 行

SH
68
字号
#!/bin/sh# This script is to announce a message on a server automatically# and repeatedly.  It is intended for server admin use.# Here is an example:## announce.sh localhost account password 30 "Attention: Here is an#   announcement\nAnd here is another announcement"## The bnchat program can be obtained from the bnetd package.BNCHAT=bnchatPIPE="/tmp/pipe-bnannounce-$$"cleanup () {        kill -9 "${pid}" 2> /dev/null        rm -f "${PIPE}" 2> /dev/null        exit 0}if [ -z "$4" ]; then        echo -e "Usage: $0 server account password interval [msgs] ..."        echo -e "   server    server ip or hostname"        echo -e "   account   your server account"        echo -e "   password  password for your account"        echo -e "   interval  time intervals between announce in seconds"        echo -e "   [msgs]    messages you want to announce"        echo        echo -e "Notes: Your account should have announce or admin permissions"        echo -e "       If interval is zero then bnannounce will only print"        echo -e "       one copy of the announcement."        echo        exitfirm -f "${PIPE}"mknod "${PIPE}" p > /dev/nullif [ $? -ne 0 ] ; then        echo "$0: failed to make pipe file ${PIPE}, check your permissions." >&2        exit 1fiserver="$1"user="$2"pass="$3"interval="$4"shift 4msg="`echo -e "$*" | sed -e 's/^/\/announce /g'`""${BNCHAT}" < "${PIPE}" > /dev/null 2>&1 &pid="$!"trap "eval cleanup" SIGINT SIGQUIT SIGTERM EXITecho -e "${user}" > "${PIPE}"echo -e "${pass}" > "${PIPE}"echo "/join Support" > "${PIPE}"while kill -0 "${pid}" 2> /dev/null; do        echo "/announce ${msg}" > "${PIPE}"        if [ "${interval}" -lt "1" ]; then            exit        fi        sleep "${interval}"doneexit

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?