Created
April 24, 2018 17:03
-
-
Save fernandolopez/3c5a6ba91fbb476dfdd656a4f5edef5e to your computer and use it in GitHub Desktop.
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/bash | |
uso() { | |
echo "Uso: $0 [c|s] nickname" >&2 | |
exit 1 | |
} | |
if [ $# -ne 2 ]; then | |
uso | |
fi | |
case "$1" in | |
c) | |
CMD="nc localhost 8008" | |
;; | |
s) | |
CMD="nc -l -p 8008" | |
;; | |
*) | |
uso | |
esac | |
NICK="$2" | |
while read line; do | |
echo "$(date -R), "$NICK" says: $line" | |
done | $CMD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment