Created
August 25, 2013 15:59
-
-
Save thonixx/6334662 to your computer and use it in GitHub Desktop.
kicks other users out of their sessions with a message
would kick root which comes from a defined destination
This file contains hidden or 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
# kick function | |
# kicks other users out of their sessions with a message | |
# would kick root which comes from a defined destination | |
function kick() { | |
if [ -z "$1" ] | |
then | |
echo "need user" | |
return | |
fi | |
tty=$(w | grep -i "$1" | head -n 1 | awk '{print $2}') | |
$(mesg y) | |
echo -n " | |
You were kicked out of your session. | |
Sorry :/ | |
" | write root "$tty" 2> /dev/null | |
$(ps faux | grep -i "$tty" | grep -v "grep" | awk '{print $2}' | xargs -n1 kill -9) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment