# cat blog >> /dev/brain 2> /proc/mind
cat blog >> /dev/brain 2> /proc/mind
# cat chatroom #!/bin/bash basename=`which basename` cat=`which cat` nc=`which ncat` tput=`which tput` function client { $nc --ssl $ip $port > >(while read line; do prompt=`echo $line | awk '{print $1}'` message=`echo $line | sed "s/$prompt//"` if [ "$prompt" == "<user0>" ] || [ "$prompt" == "<announce>" ]; then echo -e "\e[35m<announce>\e[0m\e[90m$message\e[0m" else echo -e "\e[32m$prompt\e[0m\e[36m$message\e[0m" fi $tput setaf 3 done) echo -e "\e[35m<announce>\e[0m \e[90moperator closes the chatroom.\e[0m" reset } function reset { $tput sgr0; } function server { $nc --listen --chat --ssl $ip $port } function usage { $cat << eof Usage: `$basename $0` [-h] {-m c|s} {-i ip} {-p port} Options: -m: Mode c: Client s: Server -i: IP -p: Port eof } conns='' ip='' port='' while getopts "hm:i:p:" option; do case $option in h) usage && exit ;; m) mode=$OPTARG ;; i) ip=$OPTARG ;; p) port=$OPTARG ;; esac done if [ -z $ip ] || [ -z $port ] ; then usage && exit fi trap reset SIGINT case $mode in c) client ;; s) server ;; *) usage && exit esac
cat chatroom
remote# chatroom -m s -i 192.168.1.10 -p 1234
chatroom -m s -i 192.168.1.10 -p 1234
local# chatroom -m c -i 192.168.1.10 -p 1234
chatroom -m c -i 192.168.1.10 -p 1234
Post a Comment
No comments:
Post a Comment