Skip to content

Instantly share code, notes, and snippets.

@Haeniken
Created October 22, 2021 15:48
Show Gist options
  • Save Haeniken/8afb0f0c4fad1c588e6295465eb95569 to your computer and use it in GitHub Desktop.
Save Haeniken/8afb0f0c4fad1c588e6295465eb95569 to your computer and use it in GitHub Desktop.
Messenger
#!/bin/bash
logged_on=$(who | grep -i -m 1 $1 | awk '{print $1}')
if [ -z $logged_on ]
then
echo "$1 is not logged on."
echo "Exit"
exit
fi
allowed=$(who -T | grep -i -m 1 $1 | awk '{print $2}')
if [ $allowed != "+" ]
then
echo "$1 does not allowing messaging."
echo "Exit"
exit
fi
if [ -z $2 ]
then
echo "No message parameter included."
echo "Exit"
exit
fi
# $ ./message.sh user this is long test message with using sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment