Last active
July 28, 2023 17:49
-
-
Save jessp01/51bbb455b45834ad682291b3bcc4049b to your computer and use it in GitHub Desktop.
Sends a message to all logged in users (permission to pts devices required)
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
#=============================================================================== | |
# FILE: gmessage.sh | |
# USAGE: gmessage.sh <message> [sender] | |
# DESCRIPTION: Sends a message to all logged in users (permission to pts devices required) | |
# OPTIONS: `sender` is an optional arg, $USER is used otherwise | |
# REQUIREMENTS: `toilet`, `lolcat` | |
# AUTHOR: Jesse Portnoy <[email protected]> | |
# ORGANIZATION: Packman.io | |
# CREATED: 23/04/23 20:09:32 GMT | |
# REVISION: --- | |
#=============================================================================== | |
if [ $# -lt 1 ];then | |
echo "Usage: $0 <message> [sender]" | |
exit 1 | |
fi | |
SENDER=$USER | |
MSG=$1 | |
if [ -n "$2" ];then | |
SENDER=$2 | |
fi | |
# `lolcat` often installs under /usr/games which is not always included in PATH | |
PATH=$PATH:/usr/games | |
# check that we have the needed binaries | |
for BINARY in toilet lolcat; do | |
if [ ! "`which $BINARY 2>/dev/null`" ];then | |
echo "Need to install $BINARY." | |
exit 2 | |
fi | |
done | |
for DEV in `who|awk -F " " '{print $2}'|xargs`; do | |
echo -en "\n-----\n$MSG\n-- $SENDER" | toilet -f future.tlf -t | lolcat > /dev/$DEV | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment