Last active
April 15, 2020 18:52
-
-
Save mendess/54098e31c40f6b83d5984a0634bfd3a1 to your computer and use it in GitHub Desktop.
A simple chat written in bash
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
#!/bin/bash | |
if [[ "$1" = *-h* ]] | |
then | |
cat <<EOF | |
Usage: | |
Server: $0 | |
Client: $0 SERVER_IP | |
EOF | |
exit | |
fi | |
if [ -z "$1" ] | |
then | |
cat | socat - tcp-listen:9000,reuseaddr | sed -r 's/(.*)/< \1/' | |
else | |
exec 3<>/dev/tcp/"$1"/9000 | |
{ | |
while read -r -u 3 line | |
do | |
echo '< ' "$line" | |
done | |
} & | |
while read -r myline | |
do | |
echo "$myline" >&3 | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment